← All notes

Load a Prettier config file and override options by path

Answer: You can configure Prettier via a "prettier" key in your package.json or package.yaml file, a .prettierrc file written in JSON or YAML, names such as .prettierrc.json and .prettierrc.toml, or a prettier.config.js file that exports an object. Prettier resolves the configuration file from the location of the file being formatted, then walks up the file tree until a config file is found.

There is no global configuration. That choice keeps Prettier's behavior the same when a project is copied to another computer. Options in the configuration file match the API options. Support for TypeScript configuration files requires Node.js>=22.6.0. Before Node.js v24.3.0, --experimental-strip-types is also required.

| package.json | .prettierrc | |---|---| | "prettier" key | JSON or YAML | | package.yaml | .prettierrc.json | | prettier.config.js | .prettierrc.toml | | overrides | files | | excludeFiles | excludeFiles |

Overrides

Overrides let you have different configuration for certain file extensions, folders and specific files. Each override requires files, which may be a string or an array of strings. excludeFiles may be optionally provided. Those files patterns match a file path relative to the directory that contains the configuration file, not relative to the current working directory. A pattern without a / is matched against the file name alone, so a pattern such as *.html applies at any depth.

Do not put the parser option at the top level of your configuration. Use it only inside overrides. In resolve-config.js, mergeOverrides takes configResult and filePath.

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, Configuration File; 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, Configuration File; Prettier source, resolve-config.js. MIT; MIT.

Cite this

Permanent ID: iil:note:3wzg1dag

iinventedlight. 2026. "Load a Prettier config file and override options by path." iinventedlight Library, iil:note:3wzg1dag, version of 2026-11-19. https://iinventedlight.com/library/notes/prettier-configuration/. License: CC-BY-4.0.

@misc{iil_note_3wzg1dag,
  author = {{iinventedlight}},
  title = {{Load a Prettier config file and override options by path}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-19},
  url = {https://iinventedlight.com/library/notes/prettier-configuration/},
  note = {Permanent ID iil:note:3wzg1dag. 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-configuration.md.