CSS minifier
Shrink CSS by removing comments and needless white space, leaving strings and url(...) values intact.
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/css-minify \
-H 'Content-Type: application/json' \
-d '{"input":{"text":"a {\n color: red; /* brand */\n margin: 0 auto;\n}\n\n.b > .c, .d { background: url( img/a b.png ) }"}}'
import json, urllib.request
body = {'input': {'text': 'a {\n color: red; /* brand */\n margin: 0 auto;\n}\n\n.b > .c, .d { background: url( img/a b.png ) }'}}
request = urllib.request.Request("https://setget.net/v1/tools/css-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/css-minify", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({"input":{"text":"a {\n color: red; /* brand */\n margin: 0 auto;\n}\n\n.b > .c, .d { background: url( img/a b.png ) }"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
"slug": "css-minify",
"input": {
"text": "a {\n color: red; /* brand */\n margin: 0 auto;\n}\n\n.b > .c, .d { background: url( img/a b.png ) }"
}
}
{
"input": {
"text": "a {\n color: red; /* brand */\n margin: 0 auto;\n}\n\n.b > .c, .d { background: url( img/a b.png ) }"
}
}
Endpoint: POST /v1/tools/css-minify. Over MCP: run_tool with slug: "css-minify".
Machine-readable: input schema, Markdown. Connect an agent.
Inputs
| Name | Type | Required | What it does |
|---|---|---|---|
text |
string | yes | The CSS to minify. |
Example
Input
{
"text": "a {\n color: red; /* brand */\n margin: 0 auto;\n}\n\n.b > .c, .d { background: url( img/a b.png ) }"
}Result
{
"text": "a{color:red;margin:0 auto}.b > .c,.d{background:url(img/a b.png)}",
"bytes_before": 98,
"bytes_after": 65,
"saved": 33,
"saved_percent": 33.7
}Questions
- Does it rename or merge anything?
- No. Only comments and white space that cannot matter are removed, plus the last semicolon in each block. Selectors, values and their order stay as written.
- Which comments survive?
- Comments that start with /*! are kept, because that marks licence notices.
- Why is the space around > or + kept?
- Inside calc() those spaces are required, so they are left alone everywhere to be safe.
Related tools
- CSS formatterPretty-print minified or messy CSS with one declaration per line and nested @media blocks indented.
css-format - HTML minifierShrink HTML by removing comments and needless white space, without touching pre, textarea, script or style.
html-minify - JSON minifierRemove all optional whitespace from JSON to make it as small as possible.
json-minify - .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 - Card number (Luhn) and IBAN validatorCheck a card number with the Luhn checksum and name its network, or check an IBAN by length and mod-97.
luhn-iban-validate