ToolLineup

JavaScript Formatter & Beautifier

This JavaScript formatter reparses your code and prints it back out from the syntax tree rather than nudging text around with pattern matching. That is what makes the result predictable: the formatter knows what is a string, what is a comment and what is structure, so it cannot accidentally reformat something inside a literal. Modern syntax is fully supported — optional chaining, nullish coalescing, async generators, class fields, private methods and JSX. Because parsing comes first, a syntax error is reported with its line and column instead of producing a half-formatted file.

How it works

Reparses the code and prints it back out, so the result is decided by the syntax tree rather than by find-and-replace. Modern syntax — optional chaining, async generators, JSX, class fields — is all supported.

Because it parses first, a syntax error is reported with its line and column instead of producing a half-formatted file.

Everything runs in your browser — nothing you paste is sent to a server.

JavaScript input
Paste JavaScript here…
Formatted JavaScript

How to format JavaScript online

  1. Paste your code into the input on the left.
  2. Set indent, wrap width, quote style and whether you want semicolons.
  3. Copy or download the formatted code.

Why it parses before it prints

The code is read into a syntax tree and printed back out from that tree, rather than nudged around with pattern matching. That is what makes the result predictable: the formatter knows what is a string, what is a comment and what is structure, so it cannot accidentally reformat something inside a literal. Modern syntax is fully supported: optional chaining, nullish coalescing, async generators, class fields, private methods and JSX.

Syntax errors are reported, not formatted around

Because the code has to parse before it can be printed, a syntax error stops the process and is reported with its line and column. That is more useful than a half-formatted file: the formatter has effectively found your typo.

Common use cases

  • Making a minified or bundled script readable enough to debug.
  • Cleaning up a snippet pasted from a blog post or an answer.
  • Applying consistent style to code from several sources before committing.

Frequently asked questions

Can it unminify JavaScript?

It can re-indent and re-wrap minified code so it becomes readable, which is usually enough to follow the logic. It cannot restore the original variable names, because minification discards them permanently.

Is modern syntax supported?

Yes — optional chaining, nullish coalescing, async generators, class fields and private methods, top-level await and JSX all format correctly.

What happens if my code has a syntax error?

Formatting stops and the error is reported with its line and column. That is more useful than a partly formatted file, and it means the formatter has effectively found the typo for you.

Can I choose single quotes and no semicolons?

Yes. Both are options, along with indent size and wrap width, so the output can match your project style.

Is my code uploaded anywhere?

No. Everything runs entirely in your browser, so nothing you paste is transmitted or stored on a server.

Related tools