CSS Minifier Tool Documentation
To minify/compress your CSS, perform a
POST
request to:https://www.toptal.com/developers/cssminifier/api/raw
With the
input
parameter set to the CSS you want to minify.Check the examples to see how to use our API in different languages.
Success Example
POST /developers/cssminifier/api/raw HTTP/1.1
Content-Type: application/x-www-form-urlencoded
input=p { color : red; }
Response:
HTTP/2 200
content-type: application/json; charset=utf-8
p{color:red}
Error Example
POST /developers/cssminifier/api/raw HTTP/1.1
Content-Type: application/x-www-form-urlencoded
input=p { color: ; }
Response:
HTTP/2 500
content-type: application/json; charset=utf-8
{ "errors": [ { "status": 422, "title": "Malformed input", "detail": "error: /* Empty property 'color' at 1:4. Ignoring. */" } ] }
Error Status Codes
If something doesn’t go as expected, these are the status code being used by the API:
- 400Missing input
- 405HTTP Method not allowed - onlyPOSTis accepted
- 406Content Type is not acceptable - onlyapplication/x-www-form-urlencodedis accepted.
- 413Too large payload - max-size is5MB.
- 422Malformed input - for invalid css.
- 429Too many requests - currently there is a limit of 30 requests per minute.