Minify JavaScript with Terser to make it smaller and faster to load, or beautify minified code with Prettier to make it readable.
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.
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.
Yes. Terser only makes changes that keep the code behaving the same. It is the same minifier most JavaScript build tools use.
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.
Yes. Modern syntax such as arrow functions, classes, private fields, async/await and ES modules is supported.
No. Minify plain JavaScript; compile TypeScript or JSX to JavaScript first.