JavaScript Pretty Print Online — Format JS Code

Unminify and beautify JavaScript with consistent 2-space indentation. Restore line breaks for control flow, ES6 classes, arrow functions, and async/await — 100% in your browser.

What is a JavaScript Pretty Printer?

A JavaScript pretty printer takes minified or single-line JS and re-emits it with line breaks at every brace, statement, and control-flow boundary, with consistent 2-space indentation. It is the fastest way to make a webpack bundle, a DevTools paste, or auto-generated code readable enough to debug.

Unlike a full opinionated formatter (Prettier, Standard, Biome) which re-prints the entire AST and may change quote style or trailing commas, a pretty printer preserves your token order and only restores whitespace. It is purely additive — your JS continues to behave identically because whitespace outside strings does not affect parsing.

How to pretty print JavaScript — 4 steps

  1. Paste your JavaScript. Copy minified bundle output, a one-line snippet from DevTools, or any JS source into the Input panel. Click Load Sample to try a demo.
  2. Click Run. The pretty printer processes the code client-side and adds indentation and line breaks.
  3. Review the output. The Output panel shows beautified JavaScript ready to read or step through.
  4. Copy the result. Click Copy to paste the formatted code into your editor, a snippet, or a code review.

Side-by-side: minified input vs pretty-printed output

Minified JavaScript

function calc(items){let total=0;for(const i of items){if(i.active){total+=i.price*i.qty;}}return total;}

Pretty Printed

function calc(items) {
  let total = 0;
  for (const i of items) {
    if (i.active) {
      total += i.price * i.qty;
    }
  }
  return total;
}

Unminify Bundles

Paste minified output from webpack, esbuild, Vite, or Terser and get readable JS with line breaks at every brace and statement.

Behaviour Preserved

Whitespace outside strings does not change semantics. Strings and template literals are detected and left untouched.

Client-Side Only

JavaScript runs in your browser. Code with API keys, proprietary algorithms, or unreleased features never leaves your device.

Common use cases

  • check_circlePretty print a minified production bundle (webpack, Vite, esbuild) to debug a runtime error
  • check_circleReformat JavaScript copied from Chrome DevTools or Firefox Console for analysis
  • check_circleUnminify a third-party library to understand its public API or behaviour
  • check_circleBeautify obfuscated JS to inspect a script flagged by a security review
  • check_circleFormat auto-generated JS from a code generator before committing to a repo
  • check_circleClean up JavaScript snippets pasted from documentation or tutorials
  • check_circleReformat a one-line bookmarklet or DevTools snippet to make it editable
  • check_circlePretty print legacy concatenated JS files before a refactor or modularisation pass

Pretty print vs Prettier vs js-beautify

A pretty printer is the lightweight option: it preserves your token order and only adds whitespace, so the diff is purely additive. js-beautify is similar but more configurable. Prettier goes further — it re-prints the AST, normalises quotes, enforces line length, and applies trailing commas. For a one-off readability pass on a minified file, a pretty printer is the fastest tool. For project-wide enforcement, configure Prettier in package.json and a pre-commit hook so every file is formatted before it lands in version control.

More than pretty printing

Escape, unescape, format, or convert JavaScript with the rest of OpenFormatter's tools — all browser-side.

Frequently Asked Questions

Does pretty printing JavaScript change behaviour?

No. Outside of strings, JavaScript is whitespace-insensitive. The pretty printer only inserts line breaks and indentation — the parsed AST and runtime behaviour stay identical. Automatic semicolon insertion (ASI) is also preserved because the formatter never removes existing semicolons or rearranges statements.

Can it unminify JavaScript from a production bundle?

Yes. Paste the minified output from webpack, Vite, esbuild, or Terser and the pretty printer restores indentation. Variable and function names that were mangled (one-letter names like a, b, c) cannot be recovered — that requires a sourcemap — but the structure becomes readable.

Does it support ES6+ syntax?

Yes. Arrow functions, template literals (backtick strings), destructuring, async/await, optional chaining (?.), nullish coalescing (??), classes, and private fields (#name) are all formatted correctly. Template literal interpolation is preserved exactly.

Why are template literals preserved exactly?

Backtick template literals can span multiple lines, contain line breaks that matter, and embed expressions via ${}. Reformatting them would change rendered output. The pretty printer detects template literal boundaries and leaves their interior untouched.

Will this fix my JavaScript syntax errors?

No. A pretty printer reformats syntactically valid JavaScript. If your code has a missing brace, unclosed string, or invalid token, run it through a linter (ESLint) or a parser (Acorn, Babel) to surface the error first, then format.

Is the JavaScript I paste sent to your servers?

No. Pretty printing runs entirely in your browser using JavaScript. Code containing API keys, proprietary algorithms, or unreleased features never leaves your device. Open DevTools → Network and click Run to verify no requests are made.

What is the difference between pretty print and beautify?

They are the same operation. Both terms describe inserting consistent indentation, line breaks, and spacing to make code readable. js-beautify and Prettier are the two most popular tools that do this — they call the operation "beautify" and "format" respectively.

How is this different from Prettier?

Prettier is an opinionated formatter that re-prints the entire AST — it normalises quote style, line length, trailing commas, and many other choices. This pretty printer is lighter: it preserves your existing token order and only adds line breaks and indentation. Use this for quick unminification; use Prettier for project-wide enforcement.

JavaScript Pretty Print Online — Format JS Code