Helper-KitCode Tools

JavaScript Minifier & Beautifier

Minify JavaScript with Terser to make it smaller and faster to load, or beautify minified code with Prettier to make it readable.

JavaScript
Try an example:
Minified JavaScript

More:CSS MinifierHTML MinifierJSON BeautifierRegex Tester

Minifying uses Terser and beautifying uses Prettier, the same tools used by professional build systems, so strings, comments and line-break rules are handled correctly. Syntax errors are shown with their line and column. Everything runs in your browser; your code is never uploaded.

About This Tool

Paste JavaScript, open a .js file or drop one in. Minify mode uses Terser, the minifier used by most professional build tools. It removes whitespace and comments, simplifies code and can shorten local variable names, which usually saves far more than removing spaces alone. ES modules with import and export are detected automatically. Options let you shorten variable names or keep them, remove console.log calls, and keep license comments that start with /*!. The result shows the original, minified and gzipped sizes. If the code has a syntax error, the message shows the exact line and column, and "Show in input" jumps to it. Beautify mode uses Prettier to turn minified or messy code into clean, indented JavaScript, with a choice of 2 spaces, 4 spaces or tabs and single or double quotes. Everything runs in your browser; your code is never uploaded.

Common Use Cases

  • Shrinking a script before adding it to a website
  • Reading minified code from a library or a live website
  • Removing console.log calls before release
  • Finding the exact line of a syntax error
  • Formatting code consistently before sharing it

Frequently Asked Questions

Is minified code safe to use?

Yes. Terser only makes changes that keep the code behaving the same. It is the same minifier most JavaScript build tools use.

Does it rename variables?

By default it shortens local variable and function names, which saves the most space. Global names and object properties are not renamed. Untick "Shorten variable names" to keep all names.

Does it support modern JavaScript?

Yes. Modern syntax such as arrow functions, classes, private fields, async/await and ES modules is supported.

Can it read TypeScript or JSX?

No. Minify plain JavaScript; compile TypeScript or JSX to JavaScript first.

Was this tool helpful?

More in this category