Skip to content
Latchkey

.prettierignore: Exclude Files From Formatting

.prettierignore tells Prettier which files and folders to leave untouched, using the same syntax as .gitignore.

Build output, vendored code, and generated files should not be formatted. A .prettierignore keeps them out of both --write and --check.

What it does

Prettier reads a .prettierignore file from the working directory and skips any matching path. Patterns follow gitignore rules: globs, directory names, negation with a leading exclamation mark, and comments with a leading hash. Prettier also ignores node_modules by default unless you pass --with-node-modules.

Common usage

.prettierignore
# .prettierignore
dist/
build/
coverage/
*.min.js
package-lock.json
# keep formatting this one despite the rule above
!src/keep.min.js

Options

Pattern / flagWhat it does
dist/Ignore an entire directory
*.min.jsIgnore by glob
!pathRe-include a path excluded by an earlier rule
--ignore-path <file>Use a different ignore file (can repeat)
--with-node-modulesDo not auto-ignore node_modules

In CI

Keep .prettierignore aligned with what your build generates so CI does not flag generated files. From Prettier 3, you can pass --ignore-path multiple times, for example to also honor .gitignore. Run the check from the repo root so the ignore file at the root applies.

Common errors in CI

If CI flags a file you meant to skip, the ignore file is usually not at the directory Prettier runs from, or the pattern does not match the path as Prettier sees it (relative to the ignore file). A negation that does not work often means a parent directory was excluded, which cannot be re-included by negating a file inside it.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →