xtract.bot

JavaScript minify

Try it interactively →
POST /api/js-minify

Minify JavaScript or TypeScript: rename locals, remove dead code, collapse whitespace. Modern ES syntax supported (top-level await, optional chaining, nullish coalescing).

Compresses a JavaScript or TypeScript source to its smallest equivalent form. Local variables are renamed to single letters, unreachable / unused code is removed, whitespace and comments are stripped, and constant expressions are folded. TypeScript inputs are accepted directly — types are stripped before minification, no separate `tsc` step required. Modern syntax is supported: top-level `await`, optional chaining, nullish coalescing, private class fields, decorators.

Inputs

NameTypeDefaultDescription
codestringSource to minify (UTF-8). Provide this OR `codeFile`.
codeFilefileUpload the source as a file instead of pasting it inline. Decoded as UTF-8 server-side; provide this OR `code`.
extensionenum (js | mjs | cjs | jsx | ts | mts | cts | tsx)"js"Parse mode. Determines whether the input is treated as plain JS, an ES module, JSX, or TypeScript.

Response

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

Code samples

Built from the default-js example.


curl -X POST https://api.xtract.bot/api/js-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 '{
  "code": "function add(a, b) {\n  return a + b;\n}\nconsole.log(add(1, 2));\n"
}'