How to use the Prettier config generator
- Set Print width (40–200) and Tab width (1–8), and tick Indent with tabs if you prefer tabs.
- Choose Semicolons, Single quotes, Single quotes in JSX and Trailing commas (All, ES5 or None).
- Adjust Spaces inside
{ braces }, Put > of multi-line tags on the last line and Arrow function parentheses. - Pick Line endings, Quote object keys and Markdown prose wrap.
- Decide on Only write options that differ from the defaults, then save the output as
.prettierrcin the project root.
What it does and when to use it
Prettier rewrites your code into one consistent style, so reviews stop being about commas and quotes. The .prettierrc file fixes the few choices Prettier leaves open. Each option is described in the official Prettier options page.
Use this tool when you add Prettier to a project, or when a team wants to write down its style in one place. If you also lint with ESLint, tick the Prettier option in the ESLint config generator so the two tools do not disagree. For editors and file types Prettier does not format, add basic indentation rules with the EditorConfig generator. To tidy a single snippet without setting anything up, the CSS formatter is quicker.
How it works
The tool compares each form value with Prettier 3’s defaults:
| Option | Prettier default |
|---|---|
| printWidth | 80 |
| tabWidth / useTabs | 2 / false |
| semi / singleQuote | true / false |
| trailingComma | all |
| bracketSpacing / bracketSameLine | true / false |
| arrowParens | always |
| endOfLine | lf |
| quoteProps / proseWrap | as-needed / preserve |
With Only write options that differ ticked, matching values are dropped. The file always starts with a $schema line, which lets editors such as VS Code suggest and check the options as you edit.
Worked examples
The starting values. Only two options differ from Prettier’s defaults, so the file is:
{
"$schema": "https://json.schemastore.org/prettierrc",
"printWidth": 100,
"singleQuote": true
}
Everything written out. The same form with the last box unticked lists all 13 options, including "trailingComma": "all" and "arrowParens": "always", even though they equal the defaults.
Tabs, no semicolons, Windows line endings. Print width 80, Single quotes off, Indent with tabs on, Semicolons off, Line endings CRLF. Print width and quotes are back at their defaults, so the file holds only "useTabs": true, "semi": false and "endOfLine": "crlf".
Limits and tips
- Overrides for some file types, such as a wider print width for Markdown, must be added by hand in an
overridesblock. - Format the whole project once after you add or change the file, in its own commit, so later diffs show real changes only.
- Add a
.prettierignorefor generated folders; Prettier also skips files listed in.gitignore.
Frequently asked questions
Why is my .prettierrc so short?
Is the starting form the same as Prettier's defaults?
Should I use LF or CRLF line endings?
Does tab width matter if I indent with spaces?
Can I use a JavaScript or YAML config instead?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.