JavaScript Formatter & Minifier
Paste JavaScript to format it with consistent indentation, or minify it to make it much smaller. Syntax errors are reported with the line and column. Minifying uses Terser, the compressor used by many build tools. Everything runs in your browser, and your code is never uploaded.
0 bytes
How to use it
- Choose Format to make code readable, or Minify to make it smaller.
- Paste your JavaScript into the input box, or press “Load sample”.
- For Format, pick the indentation, line length and brace style. For Minify, choose whether to shorten local variable names.
- Press the button, then copy the result or download it as a .js file.
Frequently asked questions
What does the JavaScript minifier do?
It removes whitespace and comments, shortens the names of local variables and simplifies expressions, using the Terser compressor. The program behaves the same, but the file is usually 30 to 60 percent smaller.
Will minifying break my code?
Not if the code is valid. Variables that other scripts use as globals keep their names, because only names inside functions are shortened. If you rely on function names or Function.prototype.toString, turn off the name-shortening option and test the result.
What if my code has a syntax error?
Minify stops and shows the error with its line and column. Format still lays the code out, with a warning, so you can find the problem.
Does it support modern JavaScript?
Yes. Classes, async and await, optional chaining, template strings and modules are supported. It does not compile TypeScript or JSX. Convert those to JavaScript first.
Is my code uploaded anywhere?
No. Everything runs in your browser.
Related tools
These tools run entirely in your browser and are provided free, without warranty. Check important results before using them in production.