JavaScript Formatter

Unminify and reindent JavaScript, including modern syntax, with the indent and brace style you prefer.

JavaScript
Formatted JavaScript
Runs locally in your browser

About the JavaScript Formatter

Reading a minified bundle, a copied snippet or a colleague's one-liner is easier once it is laid out. This formatter uses js-beautify to reindent JavaScript: one statement per line, consistent indentation inside blocks, spaces around operators, and your choice of brace placement. It understands modern syntax, including async and await, optional chaining, classes with private fields, template literals and modules, and leaves the code's behaviour untouched.

Comments and blank lines are preserved (up to two consecutive blank lines) so structure written by a person survives. Strings and regular expressions are never modified. The formatter is tolerant of code it cannot fully parse, so a minified file with an unusual construct still comes out readable, though a syntax error will not be reported; the JavaScript Validator does that.

For code that must follow Prettier's opinionated style, or for TypeScript and JSX, the TypeScript Formatter and JSX Formatter use Prettier itself. To go the other way, the JavaScript Minifier compresses code with terser.

How to use

  1. Paste JavaScript on the left or upload a .js file.
  2. Choose an indent and whether opening braces go on the same line.
  3. Copy or download the formatted code. Swap sends it to the minifier.

Common questions

Can it deobfuscate code?
It restores layout, which makes obfuscated code readable, but it does not rename variables or decode string arrays. The JS Deobfuscator unwraps simple eval wrappers.
Does it support JSX or TypeScript?
Basic JSX often formats acceptably, but use the JSX Formatter or TypeScript Formatter for correct results; they parse those syntaxes properly.
Will it change semicolons or quotes?
No. It reindents and spaces the code but keeps your semicolons and quote style. Prettier-based formatters normalise those.
Is there a file size limit?
Bundles of a few megabytes format in a few seconds. Larger files may make the editor slow to scroll; download the result instead.