About this tool
Instantly format, clean up and beautify messy JavaScript, JSON, CSS, HTML, XML and SQL — or compact it again.
Code Beautifier re-indents a messy snippet — JavaScript, JSON, CSS, HTML, XML or SQL — into readable, consistently nested code, and compacts it again on demand. Indentation for the JavaScript, CSS and HTML family is produced by js-beautify; JSON is parsed with the browser's own parser so a syntax error is reported with its exact line and column, and SQL is re-laid-out one clause per line with parenthesised sub-queries indented. It is for developers reading minified output, a log line or a snippet pasted out of a chat.
Open Code Beautifier on AltFTool — it loads instantly in your browser.
Paste a snippet into the Your code box — the limit is 500,000 characters — or press Detect language to have the tool guess what you pasted.
Set Language to JavaScript / TypeScript, JSON, CSS / SCSS / LESS, HTML, XML / SVG or SQL, pick the Action (Beautify or Minify), choose an Indent width of 2, 4 or 8 spaces, and tick Uppercase SQL keywords when the language is SQL.
The Formatted code box rewrites itself as you type, with Output lines, Input size, Output size and Size change beside it. Use Copy result, which flips to Copied!, Download to save the file shown under Download name such as formatted.js or formatted.json, or Reset to return to the example.
JavaScript, JSON, CSS, HTML, XML and SQL, with automatic language detection from the snippet's shape.
Invalid JSON comes back with a line and column, so you go straight to the trailing comma.
Comments and indentation are removed but line breaks are kept, so automatic semicolon insertion cannot change behaviour.
No. Beautifying only alters whitespace and line breaks, never tokens, so the program is identical. The one place whitespace matters in JavaScript is automatic semicolon insertion, which is why this tool's minify mode keeps every line break rather than collapsing the file onto one line.
Two is the most common default — it is what Prettier, the Google JavaScript style guide and the Node.js codebase use. Four suits Python-influenced teams and PHP's PSR-12. The width matters far less than being consistent across a repository, which is why most teams commit an .editorconfig or a Prettier config rather than arguing.
The three usual causes are a trailing comma after the last item, single quotes instead of double quotes, and unquoted property names — all legal in JavaScript object literals but forbidden by RFC 8259. This tool reports the line and column where the parser stopped, which is normally one character past the real mistake.
No. Terser or esbuild rename variables, drop dead branches and rewrite expressions, typically cutting 40–60% off a bundle; this tool only removes comments and indentation, which is closer to 10–20% and completely reversible. Use it to read code, and use a build-step minifier to ship it.