JavaScript Minifier & Beautifier

Paste JavaScript or open a .js file, choose Minify or Beautify, and press Process code. You get the result with its size, the bytes saved, and the line counts before and after.

Try an example
Mode
The file is read in your browser and placed in the box.

About this JavaScript minifier and beautifier

Minifying JavaScript removes everything a browser does not need, comments, indentation, and most spaces and line breaks, so scripts download faster. Beautifying does the reverse and lays out compressed code with one statement per line and consistent indentation, which helps when you need to read or debug someone else’s script. Both modes start from a tokenizer that understands strings, template literals with ${} expressions, regular expressions, and comments, so code inside them is never changed. The minifier keeps a line break wherever JavaScript’s automatic semicolon insertion could depend on it, and it never renames variables, so the result behaves exactly like the original.

How to minify or beautify JavaScript

  1. Add your code. Paste JavaScript, open a .js file, or press an example.
  2. Choose a mode. Pick Minify to shrink the file, with or without license comments, or Beautify with 2 spaces, 4 spaces, or tabs.
  3. Press Process code. Copy or download the result and compare the sizes. Use result as input switches modes so you can check the round trip.

Frequently asked questions

Is the minified code safe to use?

Yes. It removes only comments and whitespace that JavaScript ignores, keeps line breaks where automatic semicolon insertion could matter, and leaves strings, templates, and regular expressions untouched. Still test the result before deploying.

Does it rename variables like Terser or UglifyJS?

No. Renaming and dead-code removal need a full parser and can change behavior in edge cases. This tool keeps names, so the output is safe but usually somewhat larger than a build tool’s.

What are /*! comments?

Comments that start with /*! conventionally hold license and copyright notices that must stay in distributed files. Keep the option on to preserve them at the top of the minified code.

Can it beautify any minified script?

It can lay out most code from minifiers and bundlers. Very large files or unusual syntax may not be formatted perfectly, but the code itself is never changed.

Does it support TypeScript or JSX?

It is built for plain JavaScript. TypeScript without type-only syntax often works, but JSX markup and type annotations are not formatted specially.