Frontend Tools
HTML Minifier with Inline CSS and JS Compression
Minify HTML in your browser: strip comments and spare whitespace, keep pre and textarea content intact, compress inline CSS and JavaScript, and see bytes saved.
How to use HTML Minifier with Inline CSS and JS Compression
Paste HTML into the box and the minified version appears beside it as you type. Pick a whitespace mode, choose whether to remove comments and minify style and script blocks, then copy the result.
- Paste your HTMLPaste a snippet or a full document. Inline style and script blocks and pre sections are all handled.
- Choose whitespace handlingSafe collapses runs of spaces but keeps one between inline elements; Remove all is smaller but can join words.
- Check the saving and copyRead the before and after byte counts, test the page in a browser, then copy the minified code.
What the built-in example shows
The sample input is a commented navigation list, a pre block and a short script, 311 bytes in total. Minified with the default settings it drops to 248 bytes, 20.3% smaller. The comment and indentation disappear, block tags such as ul and li sit directly next to each other, and the run of spaces in About us collapses to one. The single space between the About us and Blog links survives, so the two links still render apart. In the script, the // greet comment goes but the // inside the https:// string stays, because the JavaScript is tokenised rather than searched with patterns.
Whitespace modes and what is never touched
Safe mode, the default, turns each run of spaces, tabs and line breaks into a single space and drops it next to block-level tags, so text renders as before. Remove all whitespace between tags also deletes lone spaces between inline elements, which can glue adjacent links or words together. Leave whitespace alone keeps text exactly as written, while comments and inline code are still processed. Content inside pre and textarea is always kept exactly, as are IE conditional comments. JSON-LD scripts are rewritten as compact JSON, and scripts of unknown types, such as templates, are left untouched.
Accuracy and data handling
After adding generated code to a project, test it in the target browsers and responsive sizes. The calculation runs in your current browser; the tool code does not send the input to a processing API.
FAQ
Does minifying HTML affect SEO?
No. Only comments and redundant whitespace are removed; tags, attributes and visible text stay the same, so search engines read identical content from a smaller file.
Why are two links stuck together after minifying?
You probably chose Remove all whitespace between tags, which deletes the space between inline elements. Switch back to Safe and one space is kept, so the page looks as it did.
Do I still need to minify HTML if my server uses gzip or Brotli?
The two work together. Compression shrinks the transfer, and removing comments and whitespace makes the source smaller first, although the extra gain on an already compressed site is usually modest.
Is the HTML I paste uploaded?
No. Minifying runs in your browser as you type, and the code you paste is not sent to the server.
More Frontend Tools
Related toolsStrip comments and whitespace from JavaScript safely, with the size saving shown.
Indent messy or minified HTML into readable, nested lines, including inline CSS and JS.
Unminify CSS into tidy, indented rules with one declaration per line.
Reformat compressed JavaScript into indented, readable code without touching strings.
Convert between px, rem, em, % and pt using your own root and parent font sizes.
Build fluid clamp() font sizes and spacing that scale between two viewport widths.