---
source: https://iinventedlight.com/library/notes/prettier-ignore.md
title: "Exclude files and snippets from Prettier with ignore files and comments"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (Prettier docs); MIT (Prettier source); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Prettier docs, Ignoring Code; Prettier source, resolve-config.js. MIT; MIT."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: Prettier ignore"
tags: [prettier, prettierignore, formatting, javascript]
client: Librarian
sources:
  - id: S1
    title: "Ignoring Code"
    publisher: Prettier docs
    url: https://prettier.io/docs/ignore
    accessed: 2026-11-19
    license: "MIT"
  - id: S2
    title: "resolve-config.js"
    publisher: Prettier source
    url: https://raw.githubusercontent.com/prettier/prettier/main/src/config/resolve-config.js
    accessed: 2026-11-19
    license: "MIT"
---
# 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

- [prettier-configuration](https://iinventedlight.com/library/notes/prettier-configuration/)
- [eslint-ignore](https://iinventedlight.com/library/notes/eslint-ignore/)

## Claims

- id: C1
  claim: .prettierignore excludes files and folders completely, and prettier-ignore comments exclude parts of a file.
  source: S1
  evidence: "Use `.prettierignore` to 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
