CSS minifier

Shrink CSS by removing comments and needless white space, leaving strings and url(...) values intact.

Input

The CSS to minify.

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

NameTypeRequiredWhat 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.