Minify JavaScript
Shrink JS files with real parsing — comments, whitespace and dead code gone, local names shortened, all on your device.
Last updated
How to use minify javascript
- Paste JavaScript into the input box, or tap Load file to read a .js file from your device.
- Press Minify JavaScript. The first run downloads the parser (~600 KB, then cached), so it takes a second; later runs are instant.
- Check the size readout: it shows the byte count before and after, plus the percentage saved.
- Copy the result to the clipboard or download it as a .min.js file. If the input has a syntax error, the tool tells you instead of emitting broken code.
Examples
Minify a small function
A commented, neatly indented helper collapses to a single compact line — same behavior, roughly half the bytes.
Strip comments and dead code
Comments vanish and a constant condition lets the minifier drop a branch that can never run.
See a syntax error reported
Broken input gets a clear error message rather than silently producing garbage output.
What is Minify JavaScript?
Minification is the last step before JavaScript ships: the code that developers read — with comments, descriptive names and generous indentation — gets rewritten into the smallest form that behaves identically. A good JavaScript minifier does far more than delete spaces. It parses the source into a syntax tree, folds constants, drops unreachable branches, shortens local variable names and collapses statements, which is exactly the pipeline this tool runs.
This js minifier uses terser, the same engine behind most production bundlers, so the output is safe for real projects: only local identifiers are mangled, string contents and public APIs stay untouched, and syntax errors are reported instead of producing broken code. Paste a script or load a .js file and you get the minified version with the exact byte counts before and after, so you can see how much bandwidth you just saved.
Because the parser runs entirely in your browser tab, nothing about your code travels anywhere — useful when the script is a client’s unreleased feature or sits behind an NDA. Minification is not obfuscation, though: the logic stays readable to anyone determined. For protecting secrets, keep them on a server; for saving bandwidth, minify away.
Frequently asked questions
Will minifying break my JavaScript?
Not with a parser-based minifier like this one. It understands the syntax tree, so it only removes what cannot change behavior — comments, whitespace, unreachable code — and only renames variables that are local to a function. Code that was valid stays valid; code with syntax errors gets an error message instead of output.
What is the difference between minify, uglify and obfuscate?
Minifying removes everything unnecessary for execution to cut file size. "Uglify" was the name of an older minifier (this tool uses its successor, terser) and the term stuck as a synonym. Obfuscation is a different goal entirely: making code hard to read on purpose, often at the cost of size and speed. This tool minifies; it does not obfuscate.
How much smaller will my file get?
Typically 30–70% depending on how commented and indented the source is. The readout under the result shows exact before and after byte counts. For delivery over the web, minified files then compress even further with gzip or brotli, which your server usually applies automatically.
Does it handle modern syntax like optional chaining and arrow functions?
Yes. The parser understands current ECMAScript, including classes, async/await, optional chaining and nullish coalescing. It minifies modern syntax without rewriting it to older forms, so what goes in as ES2022 comes out as ES2022, only smaller.
Is my code uploaded anywhere?
No. The whole pipeline — parsing, compressing, mangling — runs inside your browser tab. You can disconnect from the internet after the page loads and keep minifying. Nothing is logged or sent to a server.
Related tools
- Minify CSS
Minify CSS stylesheets locally — comments, whitespace and redundant units removed, exact savings shown.
- SVG Compressor & Optimizer
Compress SVG markup with SVGO — metadata and junk stripped, paths collapsed, with a visual preview.
- Base64 Encode/Decode
Quickly encode text to Base64 and decode Base64 back to readable text.
- JSON Formatter
Pretty-print, validate and minify JSON with helpful error messages.
- Minify HTML
Minify HTML documents locally — whitespace, comments and redundant attributes stripped, inline CSS/JS minified.
- JSON Minifier
Minify JSON to one compact line locally — validates first and shows the exact bytes saved.
Browse all developer tools.