Choose your Prettier options with switches and menus, see the effect on real code as you change them, and copy a ready-to-commit .prettierrc. Only the options you change are written, so the file stays short and readable.
Last updated:
Options and defaults match Prettier 3.x.
Options
Config file
Live preview
Formatted with your options loading…
Edit the input code
npm install --save-dev --save-exact prettier
npx prettier . --write
Advertisement
Advertisement
How to use the Prettier Config Generator
Start from a preset or keep the Prettier defaults.
Change the options you care about, such as semi, singleQuote, printWidth or trailingComma. Changed options are highlighted.
Watch the preview: the sample code is reformatted instantly. Pick another language or paste your own code.
Choose the file format (.prettierrc JSON is the most common) and copy or download it.
Save it in your project root, install Prettier and run npx prettier . --write.
What the most-changed options do
Option
Default output
Changed output
semi: false
const a = 1;
const a = 1
singleQuote: true
import x from "x";
import x from 'x';
trailingComma: "es5"
commas after the last item of arrays, objects and multi-line parameters
no comma after the last function parameter or argument
bracketSpacing: false
{ a: 1 }
{a: 1}
arrowParens: "avoid"
(x) => x * 2
x => x * 2
quoteProps: "consistent"
{ name: 1, "max-retries": 3 }
{ "name": 1, "max-retries": 3 }
bracketSameLine: true
closing > of a long JSX tag on its own line
> at the end of the last attribute line
objectWrap: "collapse"
an object stays expanded if you put a line break after {
the object is joined onto one line whenever it fits
Tips for adding Prettier to a project
Pin the version with npm install --save-dev --save-exact prettier; different versions can format code slightly differently, which causes noisy diffs.
Add a .prettierignore for build output and generated files such as dist/, coverage/ and lock files. Prettier also respects .gitignore by default.
Use overrides for file types that need different settings, for example "overrides": [{ "files": "*.md", "options": { "proseWrap": "always" } }].
Keep editors in sync: Prettier reads indentation, line endings and max_line_length from .editorconfig when its own config does not set them. Create one with the EditorConfig Generator.
Pair it with a linter: the ESLint Config Generator can add eslint-config-prettier so the two tools never fight.
Frequently asked questions
Where do I put the Prettier config file?
Save it in the root of your project, next to package.json. Prettier searches upward from each file it formats and uses the first config it finds: a "prettier" key in package.json, .prettierrc (JSON or YAML), .prettierrc.json, .prettierrc.yaml, .prettierrc.toml, or prettier.config.js / .mjs / .cjs.
Why did my trailing commas change after upgrading to Prettier 3?
Prettier 3.0 changed the default of trailingComma from es5 to all, so commas are now also added after the last function parameter and argument when they are split over several lines. Set trailingComma to es5 to keep the old behaviour.
Should I include default values in my config?
It is not required. Writing only the options you change keeps the file short and lets your project pick up improved defaults in future versions. Untick Only options that differ from defaults if your team prefers every value written out.
Does printWidth force every line to be that long or shorter?
No. printWidth is a target, not a hard limit. Prettier tries to fit code within it, but long strings, URLs or deeply nested expressions can still exceed it, and short code is never stretched to fill the line.
How do Prettier and ESLint work together?
Use Prettier for formatting and ESLint for code quality. Install eslint-config-prettier and add it last in your ESLint config to turn off ESLint rules that would conflict with Prettier's formatting.
Is my code uploaded?
No. The config is generated in your browser, and the preview runs the Prettier library locally in the page. If the library cannot be downloaded, a built-in preview of the sample code is shown instead.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.