Code Formatter & Minifier
Free online code formatter: beautify or minify HTML, CSS and JavaScript in one click, with script and style contents preserved verbatim.
How to Use
- Pick a language
Choose HTML, CSS or JavaScript, then pick Beautify or Minify.
- Paste your code
Drop the code in, or click 'Sample' to see the current language in action.
- Check stats and copy
The result panel shows input/output size, line count and the size delta; copy once it looks right.
FAQ
Will script or style contents be broken?
No. script, style, pre and textarea blocks are swapped for placeholders first, so indentation and minification only affect the outer structure before the original text is restored.
Why does JS minification keep line breaks?
Removing them can trigger automatic semicolon insertion (ASI) issues and change behaviour. This tool only strips comments and redundant whitespace for JS — for aggressive minification use a dedicated tool such as terser.
Do inline HTML elements get their own line?
No. Inline elements like span, a, strong and code stay on the same line to avoid breaking text flow, while block elements such as div, p and section are broken out and indented.
What should I do after minifying?
Run a quick regression in the browser and confirm styling and interaction still work before shipping. The tool only handles whitespace and comments, not syntax transforms.