JavaScript minify
Try it interactively →POST /api/js-minifyMinify JavaScript or TypeScript: rename locals, remove dead code, collapse whitespace. Modern ES syntax supported (top-level await, optional chaining, nullish coalescing).
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| code | string | — | Source to minify (UTF-8). Provide this OR `codeFile`. |
| codeFile | file | — | Upload the source as a file instead of pasting it inline. Decoded as UTF-8 server-side; provide this OR `code`. |
| extension | enum (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"
}'