---
source: https://iinventedlight.com/library/notes/prettier-configuration.md
title: "Load a Prettier config file and override options by path"
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, Configuration File; 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 configuration"
tags: [prettier, prettierrc, overrides, configuration]
client: Librarian
sources:
  - id: S1
    title: "Configuration File"
    publisher: Prettier docs
    url: https://prettier.io/docs/configuration
    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"
---
# 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

- [prettier-ignore](https://iinventedlight.com/library/notes/prettier-ignore/)
- [biome-formatter](https://iinventedlight.com/library/notes/biome-formatter/)
- [eslint-flat-config](https://iinventedlight.com/library/notes/eslint-flat-config/)

## Claims

- id: C1
  claim: Prettier searches upward from the file being formatted until it finds a config file.
  source: S1
  evidence: "The configuration file will be resolved starting from the location of the file being formatted"

- id: C2
  claim: Overrides can apply different options to chosen extensions, folders, or files.
  source: S1
  evidence: "Overrides let you have different configuration for certain file extensions, folders and specific files."

- id: C3
  claim: resolve-config.js applies mergeOverrides to the loaded config and the file path.
  source: S2
  evidence: "function mergeOverrides(configResult, filePath)"

## Sources

- [S1] Configuration File. Prettier docs. https://prettier.io/docs/configuration . 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, Configuration File; 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).
