# Prettier — card for AI agents

Opinionated code formatter for JavaScript, TypeScript, and related languages.

Category: Linting and formatting · npm package `prettier` · latest version 3.9.10 (checked 2026-11-01)
Install: `npm install prettier`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## Prettier
- Use Prettier for formatting and a linter for catching bugs. Prettier does not handle code-quality rules such as `no-unused-vars`, `no-extra-bind` or `no-implicit-globals`.
- Do not look for individual formatting rules to toggle. Prettier has none and reprints the whole program from scratch.
- Linter formatting rules such as `max-len`, `no-mixed-spaces-and-tabs`, `keyword-spacing` and `comma-style` are the category the docs say Prettier makes unnecessary.
- Do not hand-wrap code for line length. Prettier re-prints with its own rules that take the maximum line length into account, wrapping code when necessary.
- For CI checks, the README links to the `list-different` section of the CLI docs.
- On an inconsistent existing codebase, the docs call running Prettier across it "a quick win".

## Docs written for agents
- [llms.txt (index of the docs)](https://prettier.io/llms.txt)

## What it is
- Prettier is an opinionated code formatter. The README says it parses your code and re-prints it "with its own rules that take the maximum line length into account, wrapping code when necessary." The README's own example shows a long function call split onto one argument per line. The repository was created on 2016-11-29 and is MIT licensed.
- The website describes it as a formatter that "Has few options". It lists JavaScript, JSX, Flow, TypeScript, JSON, CSS, Less, SCSS, HTML, Vue, Angular, YAML, Markdown and GraphQL. Java, PHP, Ruby, Rust, TOML and XML sit in a separate list headed "Community Plugins".
- The docs split formatting from code quality, and Prettier handles only formatting. In the docs' words: "use Prettier for formatting and linters for catching bugs!" The "Why Prettier?" page calls it the only "style guide" that is fully automatic.

## Caveats
- It catches no bugs: Prettier does nothing for code-quality rules such as `no-unused-vars`. The docs call those the most important linter rules, so you still need a linter.
- You take its style, not yours: The docs admit the output may not match your preferences. They ask you to accept that "sacrifice" in exchange for automatic formatting.
- Java, PHP, Ruby and Rust come from community plugins: The website lists Java, PHP, Ruby, Rust, TOML and XML under "Community Plugins", apart from the languages in its main list.

## Numbers (AgentGid data)
- Gid Score: 89.7 (#10 of all tools, 1 of 83 in its category)
- Used in 1,320 public projects set up for AI coding agents (21.1%)
- Downloads last week: 196,787,084 (as of 2026-11-24), +37.0% over 4 weeks
- GitHub stars: 52,444 (as of 2026-11-24)
- Last push: 2026-11-23

## Often used with
ESLint 79.2%, TypeScript 83.9%, Husky 32.0%, lint-staged 26.2%, Tailwind CSS 49.2%, Vitest 37.6%

## Checked alternatives (same job)
- Biome: https://agentgid.com/tools/biomejs/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/prettier/
- Homepage: https://prettier.io
- Repository: https://github.com/prettier/prettier
- Source: https://github.com/prettier/prettier#readme
- Source: https://github.com/prettier/prettier
- Source: https://github.com/prettier/prettier/releases
- Source: https://prettier.io
- Source: https://prettier.io/docs/comparison
- Source: https://prettier.io/docs/why-prettier


## Prettier: one automatic style for all your code

Prettier is a free code formatter. It rewrites JavaScript, TypeScript, CSS, HTML, Markdown and other files in one tidy, consistent style, without changing what the code does. Your team and your AI assistant stop arguing about spaces and line breaks, and changes show only real edits.

### Where to use it
- Tidy a whole project at once: You inherit a project, or your assistant wrote files in mixed styles; one command rewrites every file in the same style.
- Block unformatted code in checks: Every pull request is checked automatically, so code that skipped formatting fails the check instead of slipping in.
- Format files on every commit: Each time someone saves work to version control, the changed files are formatted first, so nobody waits for the server check.
- Neat code that your app writes: Your app or script generates code, settings files or snippets; pass the text through Prettier before saving or showing it.
- Format code inside a web page: A code playground, a docs site or a snippet box in your app formats what people paste, right in the browser.
- Keep assistant edits easy to review: Run Prettier after your AI assistant changes files, so the review shows real changes, not moved spaces and quotes. (idea, not from the official pages)

### How to start
- Install an exact version of Prettier in the project, so everyone formats the same way.

```
npm install --save-dev --save-exact prettier@3.9.10
```

- Format every file in the project.

```
npx prettier . --write
```

- If the project uses ESLint, add eslint-config-prettier so the two do not fight over style.

```
npm install --save-dev eslint-config-prettier
```


### License
Free to use in any project, paid or not, under the MIT license. No visible credit is needed; keep the license notice if you ship Prettier's own files, for example its browser version.

### Good to know
- Output can change between releases, even small ones. Pin one exact version so teammates and tools do not reformat each other's work.
- It only fixes layout. It does not find bugs, so pair it with a linter such as ESLint.
- It has few settings on purpose, and the team does not plan to add more.
- The browser version only formats text you give it; it ignores settings files and needs the language parts loaded by hand.
- By default it skips files listed in .gitignore and in a .prettierignore file you create.

Checked 2026-11-10 against: https://prettier.io/docs/, https://prettier.io/docs/why-prettier, https://prettier.io/docs/comparison, https://prettier.io/docs/option-philosophy, https://prettier.io/docs/rationale, https://prettier.io/docs/install, https://prettier.io/docs/ignore, https://prettier.io/docs/integrating-with-linters, https://prettier.io/docs/precommit, https://prettier.io/docs/configuration, https://prettier.io/docs/options, https://prettier.io/docs/api, https://prettier.io/docs/browser, https://prettier.io/docs/ci, https://github.com/prettier/prettier/blob/main/README.md, https://github.com/prettier/prettier/blob/main/LICENSE, https://github.com/prettier/prettier/blob/main/CHANGELOG.md, https://registry.npmjs.org/prettier, https://registry.npmjs.org/prettier/3.9.10

### Mistakes to avoid
- Don't: const out = prettier.format(code, opts); then using out as a string → Do: const out = await prettier.format(code, opts); (or @prettier/sync if you truly need synchronous code) (Since version 3 every public function returns a Promise; without await you get "[object Promise]".)
- Don't: npx prettier --write . in a project where Prettier is not installed → Do: npm install --save-dev --save-exact prettier@3.9.10 first, then npx prettier . --write (npx then downloads the newest Prettier, which can format differently from the project's version.)
- Don't: In the browser: prettier.format(code, { parser: "babel", plugins: [babel] }) → Do: Load the estree plugin too: plugins: [babel, estree] (and postcss, html or markdown for those languages) (The standalone build loads no plugins by itself; in our run babel alone threw ConfigError: Couldn't find plugin for AST format "estree".)
- Don't: Adding eslint-plugin-prettier so formatting shows up as ESLint errors → Do: Use eslint-config-prettier to switch off ESLint's style rules and run prettier --check separately (The docs say the plugin route is slower and fills the editor with red lines.)
- Don't: Passing a custom parser function in options.parser (Prettier 2 style) → Do: Wrap the parser in a plugin object and pass it in options.plugins (The custom parser option was removed in 3.0 in favour of plugins.)

### Questions
- Will Prettier change what my code does? It should not. Its first rule is to output valid code that behaves exactly as before; the docs ask to report any case where it does not.
- Does Prettier replace ESLint? No. Prettier handles layout; a linter catches likely bugs. The docs suggest eslint-config-prettier to turn off ESLint's style rules.
- Can I make it format exactly the way I like? Only a little. There are a few options such as line width and quotes, and the team does not add new ones.
- How do I keep one part of a file as I wrote it? Put a // prettier-ignore comment above it in JavaScript; other languages have similar comments.
- Why did the default trailing commas change after an upgrade? In version 3.0 the default for trailing commas changed from "es5" to "all", so upgrades from version 2 add more commas.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
