Developer Tools

JavaScript Minify & Beautify

Switch between the compact and the readable form of a script with one click. Minify to see how small the code can get, with plain and gzip sizes side by side, or beautify minified code to read it. The output can be sent back to the input for a round trip.

  • Runs in your browser
  • No sign-up
  • Free to use

How to use JavaScript Minify & Beautify

  1. Paste JavaScript or open a .js file.
  2. Select Minify to compress it, or Beautify to indent it for reading.
  3. Check the size comparison, including the size after gzip.
  4. Copy or download the result, or use “Output → input” to continue working with it.

JavaScript Minify & Beautify features

Two directions, one editor

Minify and beautify share the same panes, so you can go back and forth.

Size comparison with gzip

Shows raw and gzip-compressed size before and after, which is what visitors actually download.

Real minifier

Uses Terser: removes dead code, shortens names, simplifies expressions and joins statements.

Optional console removal

Drops console.log and similar calls from production code.

Readable unminify

The beautifier restores indentation and line breaks in compressed code.

Private

Your code is processed in the browser and never uploaded.

When to use JavaScript Minify & Beautify

  • Checking how much a script shrinks before adding a build step.
  • Reading a minified third-party script to see what it does.
  • Preparing a small inline script for production.
  • Comparing the effect of name shortening and console removal on size.

JavaScript Minify & Beautify FAQ

How is this different from the separate JavaScript Formatter and Minifier?

Those tools each do one job with more options for it. This one combines both directions in a single editor and adds a size comparison, including gzip, which makes it suited to quick round trips and to answering “how much does minifying save?”.

Why show the size after gzip?

Web servers compress text files before sending them. The gzip figure is close to what a visitor really downloads. Minified code still wins after compression, though by a smaller margin than the raw numbers suggest, because gzip already removes much of the repetition that minification targets.

Can beautifying restore the original source?

It restores structure: line breaks and indentation. It cannot bring back what minification discarded, such as comments and the original names of local variables, which stay as single letters.

Is minified code safe to run?

Minification preserves behaviour for standard code. Problems are rare and come from code that depends on function or parameter names as text, or on eval with local variables. If something breaks, turn off “Shorten names” and try again.

When should I tick ES module?

When the script uses import or export at the top level, or is loaded with type="module". Module code is always in strict mode, and its top-level names are not global, which lets the minifier shorten them too.

What happens to licence comments?

Comments marked with @license, @preserve or starting with /*! are kept in the minified output, as licences usually require.

Two views of the same program

Source code is written for people and executed by machines, and the two have different needs. People want descriptive names, comments, indentation and blank lines. A browser needs none of that and has to download every byte. Minification produces the machine-oriented version, and beautification gives a human-oriented view back. Being able to move between them quickly is useful in everyday work.

A modern minifier does more than strip whitespace. It parses the program into a syntax tree and transforms it. Local names become one or two letters. Constant expressions are computed in advance. Branches that can never run are deleted, variables used once are inlined, and sequences of statements are merged. The program behaves the same and is typically a third to a half of its original size.

The size table adds perspective. Raw bytes shrink dramatically, but servers also compress responses, and compression is very good at exactly the things minification removes. After gzip, the difference between the original and the minified file is smaller, though still worth having, and the minified file also parses faster on the visitor's device. Looking at both numbers prevents both overestimating and dismissing the benefit.

The reverse direction matters for understanding code you did not write. Formatted code can be followed in a debugger and searched for the function that does a particular thing. Where a source map is available, browser developer tools use it to show the true original; where it is not, a beautifier is the next best view.

Other useful tools