Developer Tools

HTML Minifier

Minify HTML code online for free — strip comments, collapse whitespace, and shrink markup size, instantly inside your browser.

Private by default Instant results No signup
HTML MinifierLive
HTML source
Minified output
0Original size (chars)
0Minified size (chars)
0%Size reduction
Overview

What is HTML minification?

HTML minification strips out the parts of a page's markup that browsers don't need to render it correctly — comments, extra whitespace between tags, and redundant line breaks — shrinking the file without changing how the page looks or behaves. Smaller HTML means less data to download and parse, which matters most on pages with a lot of static markup or when every kilobyte counts for load time.

This tool works directly on pasted or uploaded HTML, with each cleanup rule available as an independent toggle, so it's easy to see exactly how much each one contributes to the final size.

Guide

How to use it

1Paste or upload your HTML source
2Toggle the cleanup rules you want applied
3Check the size reduction in the stat row
4Copy or download the minified result

How each option works

"Remove HTML comments" strips every <!-- comment -->block from the markup. "Collapse whitespace between tags" removes the whitespace that sits directly between two tags, which browsers ignore anyway when rendering block-level elements. "Strip line breaks & tabs" removes newline and tab characters used purely for source formatting. "Remove empty attributes" drops attributes left behind with an empty value, like a stray class="" from a templating system.

Why it helps

Features & benefits

Four independent cleanup rules you can mix and match
Live before/after size and percentage saved
Upload an .html file or download the minified result
Doesn't touch the actual markup structure or content
100% private — nothing leaves the device

Why this runs entirely in your browser

HTML source often includes unreleased pages or internal templates, so nothing is uploaded. Every cleanup rule runs in JavaScript locally in the tab, which means it keeps working offline once the page has loaded and nothing pasted into it persists after the tab is closed.

A note on whitespace-sensitive content

Collapsing whitespace and stripping line breaks is safe for typical block-level markup, but can change rendered output inside elements where whitespace is meaningful — like <pre> blocks or inline <script>/<style> content relying on specific formatting. Review the minified result before deploying it if your markup includes those elements.

Frequently asked questions

A few things people usually want to know before trusting the numbers.

For typical HTML it shouldn't — browsers already collapse whitespace between block-level tags when rendering. Content inside <pre> tags or relying on specific whitespace can be affected, so it's worth reviewing those cases.

No, it only cleans up the HTML markup itself — comments, whitespace, and empty attributes. Inline <style> and <script> content is left as-is.

It depends on how much whitespace and how many comments the original file has — the stat row shows the exact size reduction for your specific input.

Yes. Use the upload icon above the input box to load an .html file directly.

No. All minification happens locally in your browser. Nothing typed or uploaded here is sent to a server, stored, or shared.