← All notes

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

Sources

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

Permanent ID: iil:note:mvm0yg9e

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.},
}

Markdown

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.

All artifact files (JSON index)

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.