Exclude files and snippets from Prettier with ignore files and comments
Answer: Use .prettierignore to ignore certain files and folders completely. Use prettier-ignore comments to ignore parts of files. The ignore file uses gitignore syntax. It's recommended to have a .prettierignore in your project so you can run prettier --write . without mangling files you don't want, or choking on generated files.
Defaults
By default prettier ignores files in version control systems directories. Those directories are .git, .jj, .sl, .svn and .hg. It also ignores node_modules unless the --with-node-modules CLI option is specified. Prettier will also follow rules specified in the .gitignore file if that file exists in the same directory from which it is run. See also the --ignore-path CLI option.
| prettier-ignore | .prettierignore | |---|---| | comments | files and folders | | // prettier-ignore | gitignore syntax | | {/ prettier-ignore /} | prettier --write . | | JavaScript | .git .svn .hg | | abstract syntax tree | node_modules |
Comments
In JavaScript, // prettier-ignore excludes the next node in the abstract syntax tree from formatting. In JSX, the comment form is {/ prettier-ignore /}.
resolve-config.js defines mergeOverrides. That function applies overrides from a config file. .prettierignore skips a file completely. overrides set options for files that are still formatted.
See also
Claims
- id: C1 claim: .prettierignore excludes files and folders completely, and prettier-ignore comments exclude parts of a file. source: S1 evidence: "Use
.prettierignoreto ignore (i.e. not reformat) certain files and folders completely."
- id: C2 claim: Prettier ignores VCS directories and node_modules by default, and can also follow .gitignore. source: S1 evidence: "Prettier will also follow rules specified in the \".gitignore\" file"
- id: C3 claim: resolve-config.js merges a config file's overrides list when resolving options for a path. source: S2 evidence: "function mergeOverrides(configResult, filePath)"
Sources
- [S1] Ignoring Code. Prettier docs. https://prettier.io/docs/ignore . License: MIT. Accessed 2026-11-19.
- [S2] resolve-config.js. Prettier source. https://raw.githubusercontent.com/prettier/prettier/main/src/config/resolve-config.js . License: MIT. Accessed 2026-11-19.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Prettier docs, Ignoring Code; Prettier source, resolve-config.js. MIT; MIT. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Prettier docs, Ignoring Code; Prettier source, resolve-config.js. MIT; MIT.
Cite this
iinventedlight. 2026. "Exclude files and snippets from Prettier with ignore files and comments." iinventedlight Library, iil:note:mvm0yg9e, version of 2026-11-19. https://iinventedlight.com/library/notes/prettier-ignore/. License: CC-BY-4.0.
@misc{iil_note_mvm0yg9e,
author = {{iinventedlight}},
title = {{Exclude files and snippets from Prettier with ignore files and comments}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-19},
url = {https://iinventedlight.com/library/notes/prettier-ignore/},
note = {Permanent ID iil:note:mvm0yg9e. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- prettier-ignore.table.json (table; CC-BY-4.0)
- prettier-ignore.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/prettier-ignore.md.