CSS formatter

Pretty-print minified or messy CSS with one declaration per line and nested @media blocks indented.

Input

The CSS to format.
Spaces per indentation level.

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-format \
  -H 'Content-Type: application/json' \
  -d '{"input":{"text":"a{color:red;margin:0 auto}@media (min-width:600px){a,b{color:blue}}"}}'
import json, urllib.request

body = {'input': {'text': 'a{color:red;margin:0 auto}@media (min-width:600px){a,b{color:blue}}'}}
request = urllib.request.Request("https://setget.net/v1/tools/css-format", 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-format", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"text":"a{color:red;margin:0 auto}@media (min-width:600px){a,b{color:blue}}"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "css-format",
  "input": {
    "text": "a{color:red;margin:0 auto}@media (min-width:600px){a,b{color:blue}}"
  }
}
{
  "input": {
    "text": "a{color:red;margin:0 auto}@media (min-width:600px){a,b{color:blue}}"
  }
}

Endpoint: POST /v1/tools/css-format. Over MCP: run_tool with slug: "css-format". Machine-readable: input schema, Markdown. Connect an agent.

Inputs

NameTypeRequiredWhat it does
text string yes The CSS to format.
indent integer no Spaces per indentation level. Default: 2. From 1 to 8.

Example

Input
{
  "text": "a{color:red;margin:0 auto}@media (min-width:600px){a,b{color:blue}}"
}
Result
{
  "text": "a {\n  color: red;\n  margin: 0 auto;\n}\n\n@media (min-width: 600px) {\n  a, b {\n    color: blue;\n  }\n}"
}

Questions

Does formatting change what the CSS does?
No. Only white space changes, and a semicolon is added after the last declaration of each block.
Does it handle nesting?
Yes. @media, @supports, @layer, @keyframes and nested rules are indented one level per block.