HTML minifier
Shrink HTML by removing comments and needless white space, without touching pre, textarea, script or style.
Input
Result
Fill in the input and press Run.
Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.
Use it from code or an agent
curl -s https://setget.net/v1/tools/html-minify \
-H 'Content-Type: application/json' \
-d '{"input":{"text":"<div>\n <p> Hello <b>world</b> </p>\n <!-- note -->\n <pre> a b </pre>\n</div>"}}'
import json, urllib.request
body = {'input': {'text': '<div>\n <p> Hello <b>world</b> </p>\n <!-- note -->\n <pre> a b </pre>\n</div>'}}
request = urllib.request.Request("https://setget.net/v1/tools/html-minify", json.dumps(body).encode(),
{"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/html-minify", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({"input":{"text":"<div>\n <p> Hello <b>world</b> </p>\n <!-- note -->\n <pre> a b </pre>\n</div>"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
"slug": "html-minify",
"input": {
"text": "<div>\n <p> Hello <b>world</b> </p>\n <!-- note -->\n <pre> a b </pre>\n</div>"
}
}
{
"input": {
"text": "<div>\n <p> Hello <b>world</b> </p>\n <!-- note -->\n <pre> a b </pre>\n</div>"
}
}
Endpoint: POST /v1/tools/html-minify. Over MCP: run_tool with slug: "html-minify".
Machine-readable: input schema, Markdown. Connect an agent.
Inputs
| Name | Type | Required | What it does |
|---|---|---|---|
text |
string | yes | The HTML to minify. |
keep_comments |
boolean | no | Keep ordinary comments. Conditional comments are always kept. Default: false. |
Example
Input
{
"text": "<div>\n <p> Hello <b>world</b> </p>\n <!-- note -->\n <pre> a b </pre>\n</div>"
}Result
{
"text": "<div><p>Hello <b>world</b></p><pre> a b </pre></div>",
"bytes_before": 80,
"bytes_after": 53,
"saved": 27,
"saved_percent": 33.8
}Questions
- Is a space between two words ever removed?
- No. Runs of white space are collapsed to one space, and removed completely only next to block-level tags such as div or p, where browsers ignore them anyway.
- Are inline scripts and styles minified?
- No. Their content is copied exactly. Use the CSS minifier for style sheets.
Related tools
- HTML formatterRe-indent HTML so the nesting is easy to read, leaving pre, textarea, script and style content untouched.
html-format - CSS minifierShrink CSS by removing comments and needless white space, leaving strings and url(...) values intact.
css-minify - JSON minifierRemove all optional whitespace from JSON to make it as small as possible.
json-minify - Gzip compress and decompressCompress text with gzip to base64 and see the size saved, or decompress base64 gzip data.
gzip - .gitignore testerCheck which paths a .gitignore file ignores and which line decided each one, using real Git matching rules.
gitignore-test - Cache-Control explainerExplain a Cache-Control header directive by directive and how browsers and CDNs will treat the response.
cache-control-explain