JavaScript Formatter and Minifier
Paste JavaScript, then choose Format to make it easier to read or Minify to make it smaller. Minify runs in a background worker, so the page stays responsive. TypeScript syntax is not supported. Renaming variables and optimizing code are off by default because they can change how the program behaves.
JavaScript Formatter and Minifier runs entirely in your browser: the text you paste is never sent to a server. It is free and needs no sign-up.
How to use it
- Paste your JavaScript In the JavaScript Formatter and Minifier, paste code into the input, up to 1,000,000 characters. TypeScript and JSX are not supported, and code containing JSX is kept as written.
- Choose Format or Minify Format spreads the code over several lines with an indent of 2 spaces, 4 spaces or a tab, and a line width of No limit, 80 or 120 characters. Minify removes comments and extra spaces, and runs in the background.
- Check the advanced options For Minify, you can tick Shorten variable names or Optimize code. Both rewrite your code and can break programs that depend on names or execution order, so test the result. Then press Copy, or Download .js.
Questions
Why is my code reported as an error or refused?
If a string, comment, template literal or regular expression is not closed, the tool keeps your input as written and shows the line and column. Minify also reports a syntax error with its position. Code containing JSX is refused and kept as written. Formatting also checks that only whitespace changed, and keeps your text if it did not.
Why does minifying stop after 15 seconds?
Minifying runs in a background worker. If it takes longer than 15 seconds, the tool stops it and keeps your input as written. For very large code, try a smaller piece first.
Which comments does Minify keep?
Minify removes ordinary comments and extra spaces. It keeps comments that start with /*! and comments that contain @license or @preserve, so license notices stay in the result. Format keeps every comment, because it only changes whitespace.