JavaScript Minifier and Beautifier
Shrink JavaScript with Terser, or format minified code so you can read it.
How to use the JavaScript Minifier and Beautifier
- Paste your codePaste JavaScript or open a .js file.
- Choose Beautify or MinifyBeautify formats the code. Minify uses Terser to remove spaces and comments and shorten variable names.
- Copy the resultCheck the size saving, then copy or download the file.
Example
The sample counter function minifies from 490 bytes to 210 bytes, a saving of about 57%, while the /*! MIT License */ line is kept.
Beautify does the reverse: one-line minified code is spread over indented lines so you can read and debug it.
Frequently asked questions
Which minifier does this use?
Terser, the same JavaScript minifier used by most build tools. It supports modern JavaScript (ES2020), including arrow functions, classes and async code.
What do the options do?
“Shorten names” renames local variables to single letters. “Compress code” rewrites code into shorter equivalent forms. “Keep license comments” keeps comments that start with /*! or contain @license.
Why does it say there is a syntax error?
Terser has to understand your code to minify it. Fix the line and column it reports. TypeScript and JSX need to be compiled to plain JavaScript first.
Is my code uploaded?
No. The minifier is downloaded once and then runs in your browser.