Free · runs in your browser · no upload · no quota
JavaScript Minifier & Beautifier
Paste JavaScript to minify it for production — shorter names, no whitespace, dead code removed — or beautify minified code back into readable, indented JavaScript. It runs terser, the minifier behind most build tools, right in your browser.
Good to know
License comments are kept.
Comments that start with /*! or contain @license or @preserve are kept by default, as most licenses ask. Untick the option to remove them too.
console.log only when you ask.
Remove console.log drops console calls entirely, which is handy for production builds but hides logging you may rely on. It is off by default.
Minify once, from the source.
Keep your original file. Minifying beautified code again works, but you lose the original names and comments for good once you overwrite the source.
How to Minify or Beautify JavaScript
- Add your code
Paste JavaScript into the left box, drop a .js file onto it or click Open file. - Choose Minify or Beautify
Minify makes the smallest code that still runs the same; untick Shorten names to keep them readable, tick Remove console.log for production. Beautify lays minified code out with indentation. - Copy or download
The result appears on the right with the size before and after. Copy it, or download it as a .js file.
Example
function greet(name) {
// say hello
var message = 'Hello, ' + name;
return message;
}function greet(e){return"Hello, "+e}Frequently Asked Questions
-
What does minifying JavaScript do?It removes everything the browser does not need — spaces, line breaks and comments — renames local variables to single letters, and simplifies code where the result is guaranteed to be the same. Files usually shrink by 40–70%, so pages load faster. The code behaves exactly as before.
-
Can I unminify JavaScript?Yes, choose Beautify: the code is laid out again with line breaks and indentation, so you can read and debug it. What minifying threw away cannot come back, though: original variable names and comments are gone, so
function greet(e)stayse. -
Is it safe for my code?The minifier is terser, the same one used by webpack, Vite, Rollup and most other build tools, with its default safe settings. Global names, property names and exported functions are never renamed, only local variables.
-
Why does it say my code is not valid?terser parses the code first and stops at the first syntax error, with its line and column. Fix that line and it runs again. Modern syntax (ES2022 and later, classes, async/await, optional chaining) is supported; TypeScript and JSX are not, compile them to JavaScript first.
-
Is my code uploaded?No. Minifying and beautifying run in your browser, so private or unreleased code never leaves your device.