TXT · Text & Data tools

HTML Minifier & Beautifier

Input HTML
Output HTML
LoadingWorker0Saved bytes0.0%Smaller0Input bytes0Output bytes0Input lines0Output lines

Minify HTML

Minify mode collapses the whitespace between tags, removes comments, and keeps closing slashes and tag casing intact so the output stays valid for XHTML-style templates and custom elements. On a typical page, whitespace and comments account for 5 to 20 percent of the file, more when the source is deeply indented.

Two options change the outcome:

  • Minify inline CSS & JS compresses <style> and <script> contents, style="..." attributes, and inline event handlers. Turn it off if inline scripts use syntax the compressor rejects.
  • Conservative whitespace collapses each whitespace run to a single space instead of removing it. Use it when the page mixes text and inline elements, because <b>bold</b> <i>italic</i> renders differently with the space removed.

Beautify HTML

Beautify mode re-indents markup with 2 spaces, 4 spaces, or tabs, and wraps long lines at 80, 100, or 120 characters. It parses the document first, so mismatched or unclosed tags surface as an error with a line number instead of producing scrambled output.

Formatting respects whitespace-sensitive elements. Content inside <pre> and <textarea> is left untouched, since re-indenting it would change what the browser displays.

Whitespace between inline elements

The most common surprise after minification is a missing space between links or buttons that sat on separate lines. Browsers render the line break between two inline elements as a space; full whitespace collapsing deletes it. If navigation items or inline labels look glued together after minifying, re-run with Conservative whitespace enabled.

Fragments and templates

Full documents are not required. A single component, an email table, or a CMS body fragment formats the same way. Template syntax from Jinja, Liquid, or Blade usually survives both modes because it lives inside text nodes and attribute values, but check the output when template tags wrap partial elements, since the parser cannot know an {% if %} block opens a tag it never sees closed.

Reading the stats

The stats row tracks input and output byte counts, line counts, and the size change as a percentage. Byte counts use UTF-8 encoding, which matches what a server actually sends. Gzip and Brotli narrow the gap between minified and unminified HTML, but minification still wins on parse time and on pages served without compression.

Frequently Asked Questions

Minify mode collapses whitespace between tags, strips HTML comments, and optionally compresses inline style and script blocks. Beautify mode re-indents markup with your chosen indentation and wrap width.

Collapsing whitespace can merge spaces that were significant between inline elements. The Conservative whitespace option keeps one space where any whitespace existed, which is the safer choice for text-heavy pages.

Yes. With Minify inline CSS & JS enabled, style blocks, script blocks, style attributes, and event handler attributes are compressed along with the markup.

Some comments carry meaning: conditional comments, server-side include markers, or template placeholders. Turn off Remove comments when your build pipeline or CMS depends on them.

Paste markup directly or open an .html or .htm file. Full documents and fragments both work, so you can format a single component snippet without wrapping it in a document.

Explore Our Tools

Browse all tools