How to use
- Paste your code, or click Load sample to try it.
- Choose JavaScript, TypeScript or JSON and set indentation, line width, semicolons and quote style.
- Click Format, or press Ctrl+Enter (⌘+Enter on Mac).
- Copy the formatted code.
Options explained
- Indent
- 2 spaces is the Prettier default and the most common style in JavaScript projects. Tab indents with tab characters.
- Line width
- Prettier wraps expressions that would go past this many characters. 80 is the default.
- Semicolons
- Turn off to omit semicolons at the ends of statements. Prettier still adds them where leaving them out would change the meaning.
- Single quotes
- Uses 'single' instead of "double" quotes for strings unless that would need more escapes.
Examples
Minified bundle. Paste a one-line minified snippet to read what it does — formatting restores indentation and line breaks, although short variable names stay short.
Team style. Match your project’s Prettier settings, for example 4-space indent, no semicolons and single quotes.
Frequently asked questions
Does it work with JSX and modern syntax?
Yes. The JavaScript mode uses Babel's parser, which understands JSX, optional chaining, class fields, top-level await and other current syntax.
Why does it say there is a syntax error?
Prettier has to parse the code before it can format it, so it stops at code that is not valid JavaScript. The message shows the line and column to look at.
Will the formatted code behave the same?
Yes. Prettier only changes whitespace, line breaks, quotes, parentheses and semicolons in ways that keep the meaning of the code.
Is my code uploaded?
No. Prettier runs in your browser, so your code stays on your device.
Privacy
This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.