HTML Minifier

Shrink HTML by removing comments and unnecessary whitespace. Inline CSS and JavaScript are minified too.

100% free. Runs entirely in your browser - your files and data never leave your device and nothing is uploaded to any server.

edit_noteInput

0 B · 0 lines

outputOutput

0 B · 0 lines

About this tool

Minify HTML to cut page weight, or beautify it to read it clearly. The minifier is whitespace-aware rather than regex-based, so it understands where whitespace actually matters and never breaks your markup.

How to use this tool

  1. Paste HTML contentInsert full HTML or snippet into the editor input.
  2. Choose minify or beautifyCompress for production delivery or expand for readability.
  3. Process and inspect outputVerify generated markup and check size or formatting differences.
  4. Copy result into workflowUse compact output in deployment or formatted output in editing/debugging.

How much does minifying HTML save?

Minifying removes comments, indentation and extra spaces, which typically cuts an HTML file by 10 to 20% before compression. With gzip or Brotli on the server the gain over the wire is smaller, but it still adds up on large pages and HTML emails.

Spaces between inline elements such as links and spans can be visible on the page, so a careful minifier keeps one where it matters.

Key features

  • Reduces HTML payload size for faster transfer and render start.
  • Beautifies compact markup for easier debugging and audits.
  • Whitespace-aware processing protects meaningful text spacing.
  • Useful for static pages, templates, and embed snippets.

Common uses

  • Optimizing landing pages before deployment.
  • Cleaning copied HTML snippets for documentation.
  • Inspecting minified third-party markup.
  • Preparing template output for review and QA.

Tips for better results

  • Minify final build artifacts, not source templates under active editing.
  • Check rendered whitespace around inline elements after compression.
  • Keep backup of original source before heavy transformations.
  • Combine with CSS/JS minification for full page optimization.

Mistakes to avoid

  • Using regex-only minifiers that can break structural HTML.
  • Ignoring meaningful spacing in inline text contexts.
  • Treating minified markup as authoring source.
  • Skipping visual checks after aggressive compression.

Frequently asked questions

Yes, when it is done with a parser rather than regular expressions. This tool tracks tags, attributes, comments and text separately, so it knows the space between two inline elements is a real word break while the indentation between block elements is not. Content inside pre and textarea is left exactly as written.

Yes - inline style and script blocks are minified too, using the same safe tokenisers as the CSS and JS tools. JSON-LD and templating blocks are detected by their type attribute and deliberately left untouched.

Ordinary comments are, but conditional comments are kept. Those are markup rather than notes, and stripping them would break the legacy browser fallbacks some pages still ship.

Typically 20-40% on hand-written, well-indented HTML. Pages that are already generated by a build tool see less benefit. The exact saving is shown under the output.

Smaller pages load a little faster, which helps users and Core Web Vitals, but minifying alone does not change rankings. Compression, image sizes and caching usually matter far more.

Whitespace between inline elements such as links or spans renders as a space. Collapsing it can join words or buttons together; the minifier keeps significant whitespace, but check inline layouts after minifying.

Yes, and it helps Gmail, which clips messages larger than about 102 KB. Keep conditional comments for Outlook (<!--[if mso]>), which some minifiers strip.

Related guides