JavaScript Minify API - Remove Comments and Whitespace
Strips // line comments and /* */ block comments while respecting string and template-literal boundaries. Collapses whitespace and removes spaces around operators and punctuation, keeping a single space after keywords (return, typeof, function, await, etc.) to preserve semantics. No identifier mangling or tree-shaking; the output is valid, readable-ish JavaScript.
Code examples
curl -X POST https://api.botoi.com/v1/minify/js \
-H "Content-Type: application/json" \
-d '{"code":"function add(a, b) {\n // sum two numbers\n return a + b;\n}"}'When to use this API
Minify user-submitted scripts at ingest
When users submit JavaScript snippets (for an analytics injector, a tag manager, or a custom widget), minify before storing. Cuts DB size and response payload.
Build-step minification for small projects
Projects that don't want a full Terser setup can run this endpoint to strip comments and whitespace. Not as aggressive as Terser/esbuild but zero-dependency.
Pre-flight before shipping inline scripts
Inline <script> blocks in HTML are often hand-written. Minify them before server rendering to reduce HTML bloat without losing source maps.
Frequently asked questions
Does this mangle identifiers?
Are source maps generated?
Does it handle template literals safely?
What about async/await and modern syntax?
Typical savings?
Get your API key
Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.