Code Beautifier
Format and beautify minified JS, CSS, HTML, or JSON code.
Make minified or messy code readable again
Code Beautifier takes a compressed or badly formatted blob of JavaScript, JSON, CSS or HTML and re-lays it out with line breaks and four-space indentation. It is useful when you have inherited a minified file, copied a response from a network panel, or received a config squashed onto one line and need to read it. The formatting runs in the browser page as soon as you press the button.
Formatting your code
- Paste your code into the Input Data box. Sample loads a one-line JavaScript function to try, and Clear empties the box.
- Open the Language drop-down and pick Auto Detect, JavaScript / JSON, CSS or HTML.
- Press Process Now. An empty box shows an error asking for code.
- Read the formatted output, which is labelled with the language used, then press Copy or Download to save it as result.txt.
How each language is handled
- JSON: if the text is valid JSON, it is parsed and re-printed with four-space indents, which gives clean, reliable output.
- JavaScript: if it is not valid JSON, the tool breaks lines around curly braces and after semicolons, then indents according to brace depth.
- CSS: spacing is normalised and each declaration goes on its own indented line, with a blank line between rules.
- HTML: a line break is inserted between adjacent tags, and nested tags are indented one level per parent.
Auto Detect looks at the start of your text: a leading angle bracket means HTML, a leading brace or square bracket means JavaScript or JSON, and text containing braces, colons and semicolons is treated as CSS. Everything else is handled as JavaScript. If it guesses wrong, choose the language yourself.
Typical uses
- Reading a minified script to trace a bug in a third-party widget.
- Pretty-printing an API response so its structure is visible.
- Tidying a one-line stylesheet snippet before editing it.
- Making pasted HTML from an email template legible.
What to expect
The JavaScript and CSS modes use simple text rules, not a full parser. A semicolon inside a for loop header or a string will cause an extra line break, nested at-rules in CSS will not gain extra indentation, and text inside HTML elements is not re-wrapped. Comments in JSON make it invalid, which sends it down the less precise JavaScript route. The result is a readability aid, so check important code before committing it.
Related Tools