Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

CSS Minifier API

Minify CSS with csso (optionally merging and reordering rules) or pretty-print it. Syntax problems the parser recovered from are returned as warnings.

POST /api/v1/tools/css-minifierMCP css_minifierDeveloper Tools

Minify CSS to shrink stylesheets, merging duplicate rules and shortening colours, or beautify it for reading. See the size before and after and the percentage saved.

Input

Send these as a JSON object. Unknown fields are rejected.

input
The CSS. (string, required)
mode
minify or format (pretty-print). (string, one of minify, format, default "minify")
restructure
When minifying, merge and reorder rules for smaller output. (boolean, default true)
keepImportantComments
When minifying, keep /*! important comments */ such as licence headers. (boolean, default true)
indent
Spaces per indent level when formatting. (integer, 1 to 8, default 2)
blankLineBetweenRules
When formatting, put a blank line between rules. (boolean, default true)
curl https://pithlab.com/api/v1/tools/css-minifier \n  -H "Authorization: Bearer $PITHLAB_KEY" \n  -H "Content-Type: application/json" \n  -d '{"input":"/* Buttons */\n.btn {\n  color: #ffffff;\n  margin: 0px 0px 0px 0px;\n}\n.btn { padding: 4px; }"}'
Example response
{
  "ok": true,
  "result": {
    "output": ".btn{color:#fff;margin:0 0 0 0}.btn{padding:4px}",
    "stats": {
      "before": 90,
      "after": 48,
      "savedPercent": 46.7
    },
    "warnings": []
  }
}