JS Minifier — Minify JavaScript to Reduce File Size
Minify JavaScript by stripping whitespace, comments, and renaming variables. ES2020+ syntax supported, runs entirely in your browser. No uploads, no limits.
JS Minifier
Minify and compress JavaScript code. Works entirely in your browser — no uploads.
JavaScript minification has been the standard production step for client-side code since the late 2000s, when jQuery’s minified build became the most-downloaded file on the web. The argument is simple: every byte of JS over the wire is a byte the engine has to parse, and parsing is on the critical path for Time to Interactive. A typical modern web page ships 200 to 500 KB of JS, of which 30 to 50 percent is whitespace, comments, and long descriptive names that the engine does not need. Minification strips all of that, producing output that runs in the same time but downloads and parses faster. The reduction is free performance.
The non-obvious decision is between safe and aggressive presets. The safe preset does only the obvious things — strips comments, collapses whitespace, removes redundant semicolons, shortens true/false/undefined to their literal forms where smaller. The aggressive preset goes further: renames local variables and function expressions to single-letter identifiers, inlines single-use variables, removes unreachable code, and simplifies boolean expressions. Both produce semantically equivalent output, but the aggressive preset can break code that depends on Function.name matching the source name (rare) or that uses eval on its own source (also rare, also a bad pattern).
For a final hand-off: if the goal is shipping JS to production, run the source through a real build pipeline (esbuild, Vite, Webpack) — those tools combine, minify, transpile, and tree-shake in one pass. The browser tool is the right pick for one-off minification, for debugging a single file, or for inspecting what a minifier does to code you did not write. If the goal is debugging a production issue, generate a source map in your build pipeline and keep it separate from the shipped file — the minified code is functionally identical to the source, but reading it without a source map is painful.
How to use
Paste your JavaScript
Drop the JS into the input area, or load a .js file. The minifier accepts modern ES2020+ syntax — arrow functions, async/await, optional chaining, nullish coalescing, top-level await — and parses them correctly.
Pick a minification level
Safe (default) strips whitespace and comments, preserves every variable and function name. Aggressive also renames local variables and functions to short identifiers, which adds another 5-15% reduction.
Copy or download the result
Copy the minified JS to your clipboard, or download it as a .min.js file. The size reduction percentage is shown above the download button so you can verify the gain.
Frequently asked
Does minification change the runtime behavior?
No. The minified JS produces the exact same execution, the same scope chain, and the same output for every input. The only changes are whitespace removal, comment stripping, and local identifier shortening — all of which are invisible to the JS engine.
How much smaller is minified JS?
Typical reduction is 30 to 50 percent for hand-written JS and 10 to 25 percent for already-minified framework output. Highly-commented libraries with descriptive names can shrink by 60 percent or more. The savings are bandwidth and parse time, not execution time — modern engines parse minified and unminified code at similar speeds.
What is the difference between this and a JS bundler?
A bundler (Webpack, Vite, esbuild, Rollup) combines multiple JS files into one, resolves imports, and handles tree-shaking. A minifier (this tool) reduces the size of a single JS file. Most build pipelines run both: bundle first, then minify the bundle.
Is the source map included?
No — minified JS has no source map by default. For production debugging, generate a source map in your build pipeline (the `--sourcemap` flag in esbuild, Rollup, or Terser) and keep it separate from the shipped .min.js file. The source map is never shipped to production.
Will this work on TypeScript or JSX?
TypeScript syntax (type annotations, interfaces, generics) is not valid JS — the minifier will not parse it. JSX is valid JS (it is sugar for `React.createElement` calls) and parses, but the output may not run correctly without the JSX transform. Strip types and JSX in your build pipeline before minifying.
Limitations
- No TypeScript or JSXTypeScript type annotations are not valid JS — strip them with `tsc` or `esbuild` first. JSX parses but the output may not run without a JSX-aware transform. The minifier handles plain JS only.
- No source map outputThe minified JS does not include a source map. For production debugging, generate one in your build pipeline and keep it separate from the shipped file. The minifier here is the right pick for one-off minification, not for a complete build setup.
- Aggressive mode may rename public APIsThe aggressive level renames local variables and function expressions to short identifiers. Top-level `export`ed functions and `globalThis`-attached APIs are preserved, but if your code relies on `Function.name` matching the source name, use the safe preset.
Platform notes
- macOS
- For command-line work, `npx terser input.js -o output.min.js` is the standard equivalent. The browser tool is the right pick for one-off minification where installing Node and Terser is not worth the setup time.
- Windows
- PowerShell cannot minify JS natively. The browser tool is the right pick for ad-hoc work; for build pipelines, use esbuild or Terser through npm. The minification algorithm here matches Terser's safe preset for the same input.
- Linux
- The standard CLI equivalent is `npx terser input.js -o output.min.js` or `npx esbuild --minify input.js`. The browser tool is the right pick for JS pasted from a chat, an email, or a documentation page where retyping into a terminal is impractical.
- Web
- Runs entirely client-side. Works offline once the page has loaded. Useful for restricted environments where command-line tools or a Node.js install are not available.