xtract.bot
POST /api/css-minify

Minify CSS for production. Removes whitespace and comments, shortens values, dedupes rules. Optional source map. Modern CSS supported (nested rules, custom properties, container queries).

Compresses a CSS document to its smallest equivalent form. Whitespace and comments are removed; numeric values are shortened (`0.5px` → `.5px`); colours are converted to their shortest representation; redundant declarations are dropped. Modern CSS features are supported: nested rules, custom properties, container queries, `@layer`, `@scope`, and the colour-related additions from CSS Color Module 4 / 5. For an even smaller bundle, gzip- or zstd-compress the output with the matching tools.

Inputs

NameTypeDefaultDescription
cssstringSource stylesheet (UTF-8). Provide this OR `cssFile`.
cssFilefileUpload the stylesheet as a file instead of pasting it inline. Decoded as UTF-8 server-side; provide this OR `css`.
filenamestring"input.css"Filename used in warnings / errors. Doesn't affect the output bytes.
errorRecoverybooleanfalseWhen true, recover from parse errors and emit what could be parsed; warnings list the problems.

Response

Modes: json, binary. Cache: yes (24h TTL).

Code samples

Built from the default example.


curl -X POST https://api.xtract.bot/api/css-minify \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
  -H "X-Api-Key: $XTRACT_API_KEY" \
  -d '{
  "css": "body {\n  background-color: #ffffff;\n  color: rgb(0, 0, 0);\n  margin: 0px 0px 0px 0px;\n}\n"
}'