JavaScript Minifier and Beautifier Online
This javascript minifier beautifier makes code smaller or easier to read. Paste JS and minify it to strip spaces and shorten names for faster pages, or beautify it with clean indentation to debug. See the size saved and copy or download the result.
JavaScript Minifier & Beautifier
Terser minify and js-beautify.
How to use the JavaScript Minifier & Beautifier
- Paste your JavaScript.
- Choose compress, mangle and other options.
- Press Minify or Beautify.
- Copy or download the result.
How it works
Minify uses Terser, the minifier behind most build tools: it parses the code, removes comments and whitespace, simplifies expressions and shortens local variable names. The Terser library is loaded only when you press Minify. Beautify uses js-beautify to re-indent code.
Example
The sample add() function shrinks to about function add(n,d){return n+d}console.log(add(2,3)); which is over 60% smaller.
Frequently asked questions
Will minifying break my code?
Terser is safe for valid code. Keep the original source for editing.
Can I un-minify code?
Beautify restores formatting, but original names and comments cannot be recovered.
Is my code uploaded?
No. It runs in your browser.
See also: CSS Minifier and Beautifier, HTML Formatter and Minifier.
Minify or beautify JavaScript
How to use it
- Paste your JavaScript.
- Pick minify or beautify.
- Check the result and size.
- Copy or download.
More questions
Will minifying break my code?
It should not, but test before you ship.
Can it format minified code?
Yes. Beautify minified code to make it readable with spacing and line breaks.
Is my code uploaded?
No. Everything stays in your browser on your device.
Related tools: CSS Minifier and Beautifier, HTML Formatter and Minifier, JSON Formatter & Validator.