HTML Minifier
Remove comments and extra whitespace from HTML.
HTML Minifier is a a browser-based developer utility for common formatting, encoding, conversion, inspection, and debugging tasks.
Loading the interactive tool… This page needs JavaScript to run the HTML Minifier.
How to use HTML Minifier
- Paste the data, code, token, or value you need to inspect.
- Set any format, encoding, or validation options.
- Run the tool and inspect the result or diagnostic output.
- Copy the output into your terminal, editor, API client, or project.
How HTML Minifier works
This tool removes HTML comments, deletes whitespace between adjacent tags, and collapses runs of two or more spaces or line breaks into one space. It is a regex-based cleanup, so it does not remove optional tags, shorten attributes or touch inline scripts and styles, and whitespace inside pre or textarea blocks can be affected. Review the output for those.
Worked example
Input: a div on several lines containing a paragraph with the text Hi, and an HTML comment → Output: the div, paragraph and Hi joined on one line with no comment and no spaces between tags.
Common uses
- Reduce the size of a small HTML snippet before embedding it.
- Strip comments from a template before sharing it publicly.
- Compare the size of a block of markup before and after whitespace removal.
Best for
- developer workflows
- quick html minifier tasks
- browser-based utility work
Tips for better results
- Validate the output before using it in production code.
- Treat tokens, credentials, and secrets as sensitive even when processing happens locally.
- For large payloads, keep an original copy so you can compare changes.
Frequently asked questions
What does the HTML minifier remove?
Comments and unnecessary whitespace between tags.
Is it safe for inline scripts?
Whitespace inside script and pre elements should be reviewed after minifying.
How much will it save?
Usually 5–20% depending on how much whitespace and comments the page contains.
Related tools
- CSS Minifier — Remove comments and whitespace from CSS.
- HTML Formatter — Format HTML markup locally.
- JSON Minifier — Remove JSON whitespace for compact payloads.
- AI Token Cost Calculator — Estimate LLM API cost from tokens, requests and per-token prices.
- Base32 Encoder/Decoder — Encode or decode text as Base32.
- Base64 Encoder/Decoder — Encode or decode UTF-8 text as Base64.