Code Beautifier
Reformat HTML, CSS, JavaScript, TypeScript, JSON or Markdown with Prettier, or minify HTML, CSS, JavaScript and JSON, entirely in your browser.
Results are provided as is, for general information. Check anything important before relying on it. See the Terms of Use.
About Code Beautifier
Paste HTML, CSS, SCSS, Less, JavaScript, TypeScript, JSON or Markdown and get it reindented and consistently formatted by Prettier's standalone build — the same engine editors run on save. Print width, indent width, and (for JavaScript and TypeScript) semicolons and quote style are adjustable. Invalid syntax is reported with the line and column Prettier stopped at, rather than silently returning half a result. Switch Mode to Minify to go the other way for HTML, CSS, JavaScript and JSON: comments and unneeded whitespace are removed, JavaScript is also shortened by Terser, and the page shows the bytes saved. Prettier's parser for the language you pick is loaded on demand — choosing CSS never downloads the multi-megabyte TypeScript parser — and everything runs in your browser, so nothing is uploaded.
When to use Code Beautifier
Code Beautifier FAQ
Does it change my code's behaviour?
Beautify mode does not. Prettier only rewrites whitespace, line breaks, quote style and a few equivalent syntactic forms (it will add semicolons, or turn double quotes into single). It never renames anything, reorders logic, or removes code. The formatted output runs identically to the input.
Can it minify instead of expand?
Yes: choose Minify in the Mode box for HTML, CSS, JavaScript or JSON. It is aimed at snippets, not a replacement for a build pipeline that bundles, tree-shakes and builds source maps. Minified code is harder to debug, so keep the original.
How safe is minifying? What exactly does it remove?
CSS and HTML are minified conservatively: comments and whitespace that cannot change meaning go, and nothing is rewritten. CSS keeps the spaces that matter (descendant selectors, inside calc(), before a parenthesis in a media query), strings and url() contents, and /*! licence */ comments. HTML keeps one space between inline elements, leaves pre, textarea, script and style bodies and attribute values exactly as written, and keeps IE conditional comments. The block-tag option removes whitespace next to block elements; turn it off if your CSS shows list items or similar inline, because the gap between them is then visible. JSON loses only whitespace outside strings, so long numbers are never rounded. JavaScript goes through Terser, which also compresses and renames local variables; top-level names are kept, so a pasted script still works as a classic script. Always run the result before shipping it.
Why can't it minify TypeScript, SCSS, Less or Markdown?
Safe minification needs a real parser for each language. Whitespace in Markdown is meaningful, SCSS and Less have nesting and // comments, and TypeScript has to be compiled to JavaScript first. Compile those with your own tooling, then minify the output here.
Why is there no 'auto-detect language' option?
Language detection from a snippet is unreliable — a block of JSON is also valid JavaScript, SCSS is a superset of CSS, and a fragment of HTML with a script tag is ambiguous. Picking the parser explicitly means the result is predictable and the error messages point at the right thing.
Is my code sent anywhere?
No. Prettier's browser build (and Terser, for JavaScript minification) is downloaded to your device the first time you use a given language, then the work happens entirely in the page. You can use it, go offline, and it still works.