Minify JavaScript
Not every project that ships JavaScript wants to run a bundler to get it. 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.
Run — free
Runs in your browser. Free, unlimited — your data never leaves this page.
When you need minification but not a build system
A browser extension with a handful of standalone scripts, a small widget embedded on third-party sites, a legacy admin panel that predates any modern tooling, or a quick internal tool — none of these justify configuring a bundler, tuning its plugin ecosystem, and keeping that configuration alive across dependency updates just to shrink a file before shipping it. data.js_minify exists for exactly that gap: send the script, get back the compacted version, no toolchain required.
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.
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.
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.
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.
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.
FAQ
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.
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.
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.
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.
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, and soon from our app, email and Telegram.
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 '{"input":"…"}'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({
"input": "…"
})
});
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={
"input": "…"
},
)
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" => '{"input":"…"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"input":"…"}`)
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
{
"input": "…"
}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. |