Paste JavaScript, CSS, HTML, or JSON below and click Format for consistently indented output.
Code Beautifier
Paste JavaScript, CSS, or HTML into the input pane and click Format to get the same code back re-indented and consistently spaced - no upload, no install, and nothing leaves your browser. JSON input is pretty-printed the same way, with two-space indentation.
How the language is detected
The tool looks at what you pasted before choosing how to format it. JSON is checked first: if the input starts with {, [, a quote, a digit, or one of true, false, null, it is parsed and re-printed with JSON.stringify(value, null, 2). Otherwise the input is treated as code: it is classified as HTML when it starts with <, as CSS when it looks like one or more selector { property: value; } blocks, and as JavaScript in every other case. For code (not JSON), the page loads a self-hosted copy of the open-source js-beautify library the first time you format non-JSON input, then calls its matching function - js_beautify, css_beautify, or html_beautify - with two-space indentation.
Everything above runs in this browser tab. Pasted code is never uploaded, sent to an analytics service, or written to any server - it exists only in the page's memory until you close the tab or paste something else.
What this does not do
The tool re-indents and re-spaces code; it does not lint your code, catch logic bugs or unused variables, or rewrite your code semantically - it will not rename variables, restructure functions, or remove dead code. Language detection is a heuristic, not a parser for every language: if you paste Python, Java, or another language the tool does not recognise, the JavaScript beautifier runs on it anyway and the result may look odd, so check the output before you rely on it.
Typical uses
Reach for this tool when a teammate pastes minified JavaScript into a chat and you need to read it, when a CSS snippet from a tutorial arrives on one line and you want it indented before it goes into a stylesheet, when an API response prints as a single-line JSON blob and you want it readable without opening a separate JSON tool, or when you are cleaning up HTML copied from a browser's "Copy outerHTML" before committing it.
For the opposite job of shrinking a stylesheet for production, see the CSS minifier; to expand an already-minified stylesheet back to a readable form, see the CSS unminifier. To compare two versions of a file side by side instead of reformatting one, see the text diff tool. The developer tools hub lists the full set, every one running in-browser with no upload.
FreetoolOnline Editorial TeamFrequently Asked Questions
What does the code beautifier format?
JavaScript, CSS, and HTML source code. JSON input is pretty-printed too, using JSON.stringify with two-space indentation instead of the code beautifier.
How does it know which language I pasted?
It checks for JSON first, then looks at the input shape: text starting with < is treated as HTML, text that looks like CSS rule blocks is treated as CSS, and everything else is treated as JavaScript.
Is my code uploaded anywhere?
No. Formatting runs entirely in this browser tab; nothing you paste is sent to a server or an analytics service.
Does this replace the JSON Parser tool?
No. Use the JSON Parser when you need to validate JSON, browse it as a tree, or locate a parse error. This tool is for re-indenting JS, CSS, and HTML, with plain JSON pretty-printing as a side benefit.
Will it fix bugs in my code?
No. It only changes indentation and spacing; it does not check logic, flag unused variables, or rewrite your code.