Minify JavaScript
Make a script lighter without setting up a build: in the example, a comment line and an indented function become one line, function suma(a,b){return a+b;}, with the comment gone and every name intact. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Minified JavaScript
- // suma function suma(a, b) { return a + b; }
- Minified JavaScript
- function suma(a,b){return a+b;}
Not every project that ships JavaScript wants to run a bundler to get it.
Why JavaScript is harder to shrink than markup
Unlike a style sheet, JavaScript is a full programming language with scope, closures and dynamic behaviour, so shrinking it safely takes care. Renaming a local variable is harmless, but renaming something that is looked up by its name as text, or used by code outside the file, breaks the script. That is why careless text-based compaction has always been risky for JavaScript in a way it is not for markup or styles. This tool takes the cautious route and never renames anything: it only removes comments, indentation and the spaces and line breaks around symbols such as brackets, commas and operators.
What you get, and when it is enough
In the example, a comment line and a function spread over three indented lines come back as a single line with the comment removed. That suits a standalone script, such as the content or background script of a browser extension packaged without a bundler. The tool describes itself as basic minification and, for production builds of larger projects, recommends a minifier that reads the full structure of the code. Because it works on the text rather than on that structure, run the result once before publishing, especially if the script contains quoted text that looks like a comment.
Why JS minification is harder than it looks
Unlike CSS, JavaScript is a full programming language with scope, closures and dynamic behavior, so a minifier has to actually understand the code's structure to shrink it without breaking it — renaming a local variable is safe, but renaming something referenced dynamically by string, or relied on by code outside the minified scope, is not.
This is why naive text-based compaction has always been risky for JavaScript in a way it isn't for markup or styles, and why real minifiers parse the script into a syntax tree before touching a single character, a discipline that goes back to the earliest JS minification tools built alongside the language's rise as the web's dominant scripting layer.
What you can do with it
Browser extension scripts
A browser extension minifies its standalone content and background scripts before packaging the release, without introducing a bundler dependency.
FAQ
Will minifying break my script's behavior?
No, only whitespace, comments and provably safe renaming are applied; the code's runtime behavior stays the same.
Do I need a bundler to use this?
No, that's the point — it's built for scripts shipped outside a bundler pipeline, so you can minify without adopting a build toolchain.
Does it support modern JavaScript syntax?
Yes, standard modern syntax such as arrow functions, classes and modules is parsed and minified correctly.
Is my script source stored after minification?
No, both the submitted and minified JavaScript are deleted after the retention window and never used for training.
Does it rename my variables?
No. Names stay exactly as you wrote them; only comments, line breaks and the spaces around symbols are removed. In the example, suma, a and b keep their names and the whole function fits on one line.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/data/js-minify \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"js":"const a = 1; // nota\nconst b = 2;"}'const res = await fetch("https://api.kit.forhosting.com/data/js-minify", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"js": "const a = 1; // nota\nconst b = 2;"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/data/js-minify",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"js": "const a = 1; // nota\nconst b = 2;"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/data/js-minify", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"js":"const a = 1; // nota\\nconst b = 2;"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"js":"const a = 1; // nota\nconst b = 2;"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/data/js-minify", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"js": "const a = 1; // nota\nconst b = 2;"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "data.js_minify",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_mb | 25 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
This endpoint takes a script as-is and returns a smaller, functionally identical version, for teams that need minification without adopting an entire build toolchain.
How the request runs
Send POST /data/js-minify with the script source, and a task_id comes back immediately while minification processes in the background. The result — whitespace and comments stripped, and identifiers renamed where it's provably safe — arrives through a signed webhook call or waits behind a signed link valid for 24 hours.
Fitting into automation without a build step
Any pipeline that generates or ships JavaScript outside a conventional bundler — a CMS plugin system, a serverless function packager, a code generator, a CI job producing a single utility script — can call this endpoint as its minification stage instead of vendoring a JS parser and minifier into its own dependency tree. Billing per request with no charge on failed jobs means a deploy script can safely minify every changed file on every release without budgeting for wasted spend, and because the task is async, a batch of dozens of scripts can be submitted at once and collected as each webhook arrives rather than processed one at a time in sequence.
Integration use cases
Embeddable third-party widget
A widget embedded on customer sites minifies its script to reduce load time on pages the widget doesn't control the performance of.
Serverless function packaging
A serverless function packager minifies each generated function's JavaScript before deployment to shrink cold-start payload size.
Legacy admin panel maintenance
A legacy internal tool with no modern build system minifies its hand-written scripts through the API before each release.
Technical questions
How do I minify JavaScript with the API?
POST your script to /data/js-minify, keep the returned task_id, and collect the minified JavaScript by webhook or a signed link valid for 24 hours.
Is the JavaScript minifier API free?
No, there is no free tier or trial; it costs $0.002 per request, and a failed request is never charged.
Can I minify many scripts in bulk?
Yes, submit one async task per file and collect each result by webhook, which works well for a batch of dozens of scripts at once.
Is this endpoint live?
Yes, data.js_minify is live and accepting requests now.