JavaScript Minifier and Beautifier

Shrink JavaScript with Terser, or format minified code so you can read it.

FreeNo sign-upPrivate — runs in your browser
0 BInput size
0 BResult size
—Change
0Result lines

How to use the JavaScript Minifier and Beautifier

  1. Paste your codePaste JavaScript or open a .js file.
  2. Choose Beautify or MinifyBeautify formats the code. Minify uses Terser to remove spaces and comments and shorten variable names.
  3. 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.

Popular posts from this blog

Character Counter

Speech to Text Online

Keyboard Tester