Indent HTML neatly while keeping pre, textarea and script content intact
HTML Minifier
Strip the bytes a browser never needed from an HTML page while keeping every element and word in place.
Loading tool…
How to use html minifier
Paste HTML or open an .html file.
Choose whether to remove comments, minify CSS in style blocks and style attributes, and trim script blocks.
Compare the before and after sizes.
Copy the result or download it as .min.html.
What this tool does
- Collapses runs of whitespace to one space and removes whitespace next to block elements, where it never shows.
- Keeps the single spaces between inline elements and words so text does not run together.
- Minifies CSS in style blocks and style attributes with the same engine as the CSS minifier.
- Leaves pre and textarea content, attribute values and IE conditional comments untouched.
How the result is verified
The minified page is read again and compared with the original: every element, attribute and word of text must still be present in the same order before the download is enabled.
Frequently asked questions
Is minified HTML worth it if my server already uses gzip?
Gains are smaller with compression on, often a few percent, but every byte still has to be parsed. It helps most on large pages with lots of indentation and comments.
Will it break inline scripts?
No. Script content is only trimmed at the start and end. The code itself is passed through exactly as written.
Is my data uploaded to a server?
No. Everything you drop, paste or type is processed by code running in this browser tab. You can check it yourself: open your browser's developer tools, watch the Network panel, and use the tool. No request carries your data.
Related tools
Smaller CSS with comments, whitespace and empty rules removed safely
Edit HTML, CSS and JavaScript and run them live in a sandbox with a console
Compare two texts line by line with changed words highlighted