JavaScript Minifier Tool Documentation

To minify/compress your JavaScript, perform a
POST
request to:
https://www.toptal.com/developers/javascript-minifier/api/raw
With the
input
parameter set to the JavaScript you want to minify.
For custom minification options set the
config
parameter. Check SWC documentation for more information.

Check the examples to see how to use our API in different languages.

Success Example

POST /developers/javascript-minifier/api/raw HTTP/1.1 
Content-Type: application/x-www-form-urlencoded

input=console.log( 1 )

Response:

HTTP/2 200 
content-type: application/json; charset=utf-8

console.log(1)

Error Example

POST /developers/javascript-minifier/api/raw HTTP/1.1 
Content-Type: application/x-www-form-urlencoded

input=console.log(+1

Response:

HTTP/2 500 
content-type: application/json; charset=utf-8

{ "errors": [ { "status": 422, "title": "Malformed input", "detail": "error: Expected ',', got ';'\n --> <anon>:1:16\n |\n1 | console.log( 1 ;\n | ^\n\n\n\nCaused by:\n 0: failed to parse input file\n 1: Syntax Error" } ] }

Error Status Codes

If something doesn’t go as expected, these are the status code being used by the API:

  • 400
    Missing input
  • 405
    HTTP Method not allowed - only
    POST
    is accepted
  • 406
    Content Type is not acceptable - only
    application/x-www-form-urlencoded
    is accepted.
  • 413
    Too large payload - max-size is
    5MB
    .
  • 422
    Malformed input - for invalid javascript.
  • 429
    Too many requests - currently there is a limit of 30 requests per minute.