Prettier config generator — build a .prettierrc

Set the formatting choices your team agreed on, and the tool writes a .prettierrc JSON file, by default containing only the options that differ from Prettier 3's defaults.

Live demo · real result from this tool
Arrow function parentheses

.prettierrc

{  "$schema": "https://json.schemastore.org/prettierrc",  "printWidth": 100,  "singleQuote": true} 

Defaults are Prettier 3's. Add a .prettierignore for generated files; Prettier also respects .gitignore.

Processed on your device — nothing is uploaded.

How to use the Prettier config generator

  1. Set Print width (40–200) and Tab width (1–8), and tick Indent with tabs if you prefer tabs.
  2. Choose Semicolons, Single quotes, Single quotes in JSX and Trailing commas (All, ES5 or None).
  3. Adjust Spaces inside { braces }, Put > of multi-line tags on the last line and Arrow function parentheses.
  4. Pick Line endings, Quote object keys and Markdown prose wrap.
  5. Decide on Only write options that differ from the defaults, then save the output as .prettierrc in 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 overrides block.
  • 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 .prettierignore for generated folders; Prettier also skips files listed in .gitignore.

Frequently asked questions

Why is my .prettierrc so short?
With "Only write options that differ from the defaults" ticked, any option left at Prettier's default is not written, because Prettier applies it anyway. A short file also shows at a glance what your team changed. Untick the box to list every option.
Is the starting form the same as Prettier's defaults?
Almost. The form starts with Print width 100 and Single quotes on, which are common team choices. Prettier's own defaults are 80 and double quotes. Set them back if you want plain defaults.
Should I use LF or CRLF line endings?
LF is Prettier's default and the safe choice for a shared repository, even on Windows, because Git and most editors handle it. Choose CRLF only if a tool you depend on needs it. "Keep existing" leaves each file as it is.
Does tab width matter if I indent with spaces?
Yes. Tab width is the number of spaces per indent level. With Indent with tabs ticked, it only affects how Prettier measures line length.
Can I use a JavaScript or YAML config instead?
Yes, Prettier reads several file formats. The same options work in a prettier.config.js file or in a prettier key in package.json; only the wrapper changes.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close