Free HTML Formatter & Minifier
Minified HTML loads fast but reads terribly; hand-written HTML reads well until a CMS mangles it onto one line. This free tool fixes both directions: Format re-indents markup with a tag-aware engine that understands void elements, comments, and script/style blocks, while Minify strips comments and collapses whitespace for production deploys — all in your browser.
How to Format or Minify
- Paste your markup — full pages, snippets, or email templates.
- Click Format for readable two-space indentation with text nodes on their own lines, or Minify for the smallest valid equivalent.
- Copy the output back into your editor or build pipeline.
How the Indenter Thinks
The formatter tokenizes input into tags, comments, doctypes, and text runs. Opening tags raise the indent (except void elements like br, img, and input, which never take children), closing tags lower it first, and script/style contents pass through untouched so JavaScript and CSS survive byte-identical. Minification reverses the process: comments die, inter-tag whitespace collapses, and the document shrinks 10–30% with zero visual change.
Will formatting break my page?
No — only whitespace between tags changes, which browsers ignore outside pre and CSS white-space: pre contexts. Inline scripts and styles are preserved verbatim.
How much smaller does minified HTML get?
Typically 10–30% depending on original indentation and comment volume. Pair it with minified CSS/JS and compression for the full effect.
Is my code uploaded?
Never. Tokenizing and rendering run locally; proprietary templates stay on your machine.
Related Tools
Format stylesheets with the CSS Formatter, validate data with the JSON Formatter, and shrink scripts with the JS Minifier.