Private by design
Terser runs inside your browser. Your source code is never uploaded, stored or logged.
Free · No sign-up · Runs in your browser
Compress your JavaScript with Terser, the minifier behind webpack and Vite. Remove dead code, shorten variable names, drop console calls and ship smaller bundles, without your code ever leaving the browser.
Terser runs inside your browser. Your source code is never uploaded, stored or logged.
The same Terser engine used by webpack, Vite and Rollup: dead-code removal, constant folding and name mangling.
Classes, async/await, optional chaining, ES modules and more. Choose the ECMAScript level you ship to.
Syntax errors show the exact line and column with the offending code, so you can fix them fast.
Drop several scripts at once. They are joined safely in order into a single .min.js file.
Compare original, minified and gzipped sizes, plus a Beautify button to make minified code readable again.
Automate minification from your build scripts, CI or CMS with a single HTTP request. No key required.
POST https://jsminifier.org/api/input: your JavaScript (form-urlencoded or multipart)format=json for sizes and savings, license=0 to also drop /*! */ commentsapplication/javascript with the minified code, or 400 and the error textThe API uses our lightweight server engine (comment and whitespace removal). The browser tool above applies the full Terser optimiser.
curl -X POST https://jsminifier.org/api/ \
--data-urlencode "[email protected]" \
-o app.min.js
# sizes and savings as JSON
curl -X POST https://jsminifier.org/api/ \
--data-urlencode "[email protected]" -d format=json
const res = await fetch("https://jsminifier.org/api/", {
method: "POST",
body: new URLSearchParams({ input: code })
});
if (!res.ok) throw new Error(await res.text());
const minified = await res.text();
$ch = curl_init("https://jsminifier.org/api/");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query(["input" => $code]),
CURLOPT_RETURNTRANSFER => true,
]);
$minified = curl_exec($ch);
curl_close($ch);
import requests
r = requests.post("https://jsminifier.org/api/", data={"input": code})
r.raise_for_status()
minified = r.text
using var http = new HttpClient();
var body = new FormUrlEncodedContent(new Dictionary<string, string> {
["input"] = code
});
var res = await http.PostAsync("https://jsminifier.org/api/", body);
res.EnsureSuccessStatusCode();
string minified = await res.Content.ReadAsStringAsync();
It rewrites your code into the smallest form that behaves exactly the same. Comments and whitespace are removed, local variable names are shortened (mangling), and unreachable or unused code is dropped. Smaller files download and parse faster.
Terser, the most widely used JavaScript minifier, which also powers the production builds of webpack, Vite and Rollup. It fully supports modern JavaScript, including ES modules, classes and async functions.
No. With JavaScript enabled, Terser runs entirely in your browser and your code stays on your device. Only if JavaScript is turned off does the form fall back to our server, which minifies the code in memory and does not keep it.
It renames local variables and function parameters to short names such as a or b. Global names are left alone unless you enable Top-level, so other scripts on your page keep working.
Turn on Keep names if your code relies on function.name or class names. Enable Module for files that use import or export. If you target old browsers, set the ECMAScript level to ES5.
Yes. Comments that start with /*! or contain @license or @preserve are kept by default. Untick Keep /*! comments to remove them too.
Yes. The Beautify button reformats any JavaScript with clean indentation. Mangled variable names cannot be restored, but the structure becomes easy to read.