JavaScript Beautifier

Beautify and format minified JavaScript online for readable code — free JS formatter.

About

About the JavaScript Beautifier

Paste minified or inconsistently formatted JavaScript and get it back readable — proper indentation, consistent brace style and normalized spacing — using js-beautify, the same beautify.js engine bundled inside many code editors, without touching your actual logic.

Beautifying restores line breaks and indentation, but it can't fully undo minification: variables a minifier renamed to a, b or c keep those short names, and comments that were stripped are gone for good. For a minified script you need to understand, beautify it first, then use your editor's rename feature to give the important variables meaningful names again.

Choose what to view about this tool

Guide

Using the JavaScript Beautifier

  1. 1

    Step 1

    JavaScript is already selected below as the language.

  2. 2

    Step 2

    Paste your JS code into the input box.

  3. 3

    Step 3

    Click Beautify to see the formatted output, entirely in your browser.

  4. 4

    Step 4

    Copy the formatted code back into your editor.

  • Expands one-line or minified JavaScript into indented, multi-line code
  • Puts braces, semicolons and spacing into one consistent style
  • Keeps any comments that are still in the code
  • Indent size from 1 to 8 spaces (2 by default)
  • Copy the formatted code in one click
  • Runs in your browser — free, no sign-up, and your code is never uploaded

Front-end developers

Developers read a minified third-party script to work out what it does.

Security analysts

Analysts review packed or minified JavaScript found on a page.

Students

Students see how well-formatted JavaScript is structured.

Bloggers and teachers

Writers format snippets neatly before putting them in a post or lesson.

Beautify another language

Examples

JavaScript Beautifier examples

4 worked examples

01

Un-minifying a one-liner

Pasting function add(a,b){return a+b} returns it formatted across multiple lines with proper indentation and a space around the operator, ready to read.

02

Formatting a messy function

A function with inconsistent spacing and mixed brace styles comes back with consistent indentation (2 spaces by default) and matching brace placement throughout.

03

Restoring readable object literals

A compressed object literal like {a:1,b:2,c:3} is reformatted onto separate lines, one property per line, without changing any of its values.

04

An indent of 4

With Indent size set to 4, function f(){return 1} becomes a three-line function with its return statement indented four spaces.

FAQ

Frequently asked questions

Quick answers to common questions about the JavaScript Beautifier.

How do I beautify JavaScript?

Paste your JS code above, make sure JavaScript is selected, then click Beautify. The formatted output appears in the box below it — everything runs in your browser, using js-beautify.

Is this JavaScript beautifier free?

Yes. It's free, with no sign-up and no limit on how much code you format.

Can it un-minify code that's been compressed onto one line?

Yes — that's one of its most common uses. Paste minified JavaScript in and it comes back with proper line breaks, indentation and spacing restored.

Will beautifying change how my code behaves?

No — it only changes whitespace, indentation and brace placement; the underlying logic and behaviour stay exactly the same.

Is my code uploaded anywhere?

No. Formatting runs entirely in your browser after js-beautify loads from this site — your code never leaves your device.

Can I beautify HTML or CSS here too?

Yes — switch the language dropdown, or use the dedicated HTML beautifier or CSS beautifier page.

Can I change the indent size?

Yes. Set Indent size anywhere from 1 to 8 spaces before clicking Beautify; the default is 2.

Does it restore minified variable names?

No. Beautifying only adds line breaks and indentation. Names a minifier shortened, like a or b, stay short — the original names can't be recovered without a source map.

Can it format JSON?

It can, since JSON is valid JavaScript, but the JSON Formatter is the better fit: it also checks the JSON is valid and can sort the keys.

Still have a question? Contact us

Report a problem

JavaScript Beautifier

What went wrong?
    or paste a screenshot