JavaScript Minifier & Beautifier
Free JavaScript minifier and beautifier. Minify JS with Terser (mangle, compress, source map), see bytes and gzip saved, or beautify code in your browser.
Paste JavaScript to minify it with Terser, the same engine webpack, Vite and Rollup use: it removes whitespace and comments, shortens local variable names (mangling) and rewrites code into a smaller equivalent form (compression). Switch to Beautify to re-indent minified or messy code with js-beautify. The tool shows the original and new size, the percentage saved and an estimated gzip size, and it all runs in your browser so your code is never uploaded.
Runs in your browser. The processing engine downloads once on first use, then the tool works offline. Your files never leave your device. Free, no sign-up.
Features
- Terser compress and mangle with two passes
- Keep licence comments (/*! … */) or strip all
- Optional source map download
- Beautify with 2, 4 or tab indentation
- Byte, percentage and gzip savings
- Syntax errors shown with line and column
How to use JavaScript Minifier & Beautifier
- Paste your JavaScript or open a .js file.
- Choose Minify or Beautify and set the options (mangle, compress, comments, ES module, source map or indent size).
- Read the result on the right as you type, with the bytes and gzip size saved.
- Copy the output or download it, plus the .map file if you made a source map.
Frequently asked questions
What does minifying JavaScript do?
Minification removes characters the engine does not need, such as whitespace, comments and long local variable names, and rewrites some expressions into shorter equivalents. The code behaves the same but downloads and parses faster. It is normally done as a build step before deploying a site.
What is the difference between mangle and compress?
Mangle renames local variables and function parameters to one or two letters. Compress applies optimisations such as removing dead code, joining declarations and simplifying conditions. Using both gives the smallest output; turn them off if you only want whitespace removed.
Is minified JavaScript the same as obfuscated code?
No. Minified code is harder to read but not protected: a beautifier restores the layout, although original local variable names are lost. Anything shipped to a browser can be read, so never put secrets such as API keys in client-side JavaScript.
How much smaller does JavaScript get?
Typical hand-written code shrinks by 30 to 60 percent before gzip. Servers usually also compress files with gzip or Brotli, which is why the tool shows a gzip estimate: that is closer to what actually travels over the network.
What is a source map for?
A source map links positions in the minified file back to the original source, so browser developer tools can show readable code and correct line numbers in stack traces. Upload it next to the minified file, or keep it private and use it only when debugging.
Is my code uploaded anywhere?
No. Terser and js-beautify are downloaded once from a public CDN and then run in your browser. The code you paste stays on your device.
Related tools
- CSS Minifier & Beautifier — Minify CSS with CSSO or prettify it, with a bytes and gzip savings report
- HTML Formatter — Beautify and tidy HTML markup
- JSON Formatter — Format, validate and minify JSON
- HTML to JSX Converter — Convert HTML or SVG to React JSX/TSX: className, style objects, self-closing tags
- SVG Optimiser — Minify SVG exports and convert them to PNG
- Regex Tester — Test regular expressions with live match highlighting