Skip to main content
ToolsBay

JavaScript Formatter

Format JavaScript and TypeScript with Prettier in your browser.

Runs entirely in your browser — nothing is uploaded

Your code

1 line

Formatted code

1 line

Frequently asked questions

Does it handle TypeScript and JSX?

Yes. Switch the parser above — TypeScript for .ts files, TSX/JSX for anything containing JSX syntax. The plain JavaScript parser rejects type annotations.

Can it recover minified variable names?

No, and nothing can. Minification replaces meaningful names with single letters and discards the originals. Formatting restores the structure and indentation, which makes minified code readable, but the names are gone unless a source map exists.

Why does it fail on my file?

Prettier has to parse the code before it can print it, so a genuine syntax error stops it. The error message points at the position it gave up, which is usually at or just after the mistake.

Which style does it use?

Prettier defaults with single quotes, trailing commas and a 100-character width. Prettier is deliberately opinionated — the point is consistency, not configurability.

Formatting versus un-minifying

These are different jobs and it is worth being clear about which one a formatter does. Minification removes whitespace and renames variables, inlines functions and drops comments. A formatter reverses only the first of those.

So running minified bundle code through here gives you readable structure — you can follow the control flow, see the nesting, and set breakpoints — but the identifiers stay as a, b and t. Recovering real names requires the source map that the build produced.

Why Prettier has so few options

Prettier deliberately offers a handful of settings instead of the dozens older formatters had. The reasoning is that most formatting arguments are not worth having: any consistent style beats an inconsistent one, and removing the choice removes the argument. It parses your code into a syntax tree and prints that tree from scratch, so the output depends only on the code's meaning, never on how it was originally laid out.

For other formats, see the JSON formatter, HTML beautifier, CSS minifier and SQL formatter.

All developer tools