Account

What new tool do you want?

Developer Tools

Code Beautifier (HTML, CSS, JavaScript)

Beautify messy or minified HTML, CSS and JavaScript into clean, consistently indented code you can read and edit.

How to use

  1. 1Paste the code and pick the language.
  2. 2Choose an indent size and copy the formatted code.

Frequently asked questions

Can it un-minify code?

Yes. Minified one-line HTML, CSS or JavaScript is expanded with line breaks and indentation. Renamed variables can't be restored, though.

Does beautifying change how code runs?

No. Only whitespace is changed, so behavior stays the same.

What about JSON, SQL or XML?

Use the dedicated JSON Formatter, SQL Formatter and XML Formatter tools, which also validate the syntax.

Beautifying is not the same as deobfuscating

This tool (built on js-beautify) reconstructs line breaks and indentation from minified or inconsistently formatted HTML, CSS and JavaScript, which makes single-line minified output human-readable again. What it can't do is anything a minifier's variable-renaming pass actually destroyed: if a build tool renamed `calculateShippingCost` to `a`, beautifying restores the structure around `a` but not its original name. For code mangled by a real obfuscator (control-flow flattening, string encoding), you need a deobfuscator, not a beautifier — this tool only re-indents what's already syntactically there.

Why three languages share one tool, and why JSON lives here too

HTML, CSS/SCSS and JavaScript are grouped together because js-beautify's three beautifier functions (html, css, js) all solve the same underlying problem — turning a single stream of tokens back into nested, indented blocks — and the JavaScript option doubles as a JSON beautifier since JSON is a syntactic subset of JS expressions. That's convenient for a quick peek at a minified JSON blob, but if you need validation (catching a trailing comma or an unescaped quote), the dedicated JSON Formatter actually parses the text and will tell you where it's broken; this tool will happily indent invalid JSON without complaint.

What the indent setting changes, and what it leaves alone

The indent choice (2, 4, or tab) only affects whitespace — `end_with_newline: false` is also forced, so output won't pick up a trailing blank line your original file didn't have. Behavior is identical before and after for all three languages, since nothing except whitespace is rewritten, which is why it's safe to run on production CSS or a vendored JS file you're trying to read before patching.

Worked example: Code Beautifier

Paste the minified CSS `a{color:red;margin:0}` with Language set to CSS/SCSS, and the output is: a { color: red; margin: 0 } The selector gets its own line, the brace opens on the selector's line, and each declaration gets one indented line — structure you'd have to add back by hand otherwise. A minified JS snippet like `function f(a){if(a){return 1}return 2}` with 4-space indent expands to nested braces across five lines, each `if` block properly indented one level deeper than the function body around it.

The result does not grow a blank line at the end

Language opens on HTML. CSS or SCSS is next, and the third choice is scripts and JSON. Indent opens on 2 spaces. Choosing a tab uses a tab character. The formatted text does not add a trailing blank line. On the CSS sample, a color and a margin packed onto one line come back on their own lines, and the last property has no semicolon after it. I notice that when I compare the result with a formatter that always finishes the last declaration with a semicolon. I switch indent when the file should use tabs.

Related tools

More: Developer Tools