DevGrill

JavaScript Formatter

Beautify minified JavaScript, or minify it with Terser and catch syntax errors.

Runs in your browser

0 chars
0 chars

Reading and shrinking JavaScript

Minified JavaScript (from a website, a CDN or a bundle) is one long line. Formatting it adds the line breaks and indentation back, so you can follow what it does and find the function you're after. Variable names that were shortened stay short: formatting can't recover them.

Minify does the opposite with Terser, the minifier most bundlers use: it removes whitespace and comments, shortens local variable names and simplifies code, usually cutting the size by half or more. If the code has a syntax error, Minify shows where it is, with the line and column. Comments starting with /*! or containing @license are kept.

How to use the JavaScript Formatter

  1. Paste your JavaScript. Or load the sample shopping cart.

  2. Choose Format or Minify. Format lets you pick 2 spaces, 4 spaces or tabs.

  3. Copy the result. When minifying, the status line shows how much smaller it got.

Tips

  • Formatting never changes what the code does; it only adds whitespace.
  • Minify is also a quick syntax check: paste a snippet and it tells you exactly where an error is.
  • Beautifying code you didn't write is fine for reading and debugging; check its license before reusing it.

Frequently asked questions

Does it support TypeScript or JSX?

Formatting works for most TypeScript and JSX, since it only adds whitespace. Minify needs plain JavaScript, so compile TypeScript or JSX first.

Which JavaScript versions work?

Modern JavaScript: modules (import/export), async/await, classes, optional chaining, template literals and the rest.

Is the minified code safe to use?

Yes, it uses Terser's standard safe settings, the same kind of output bundlers produce. Test it as you would any build output.

Is my code uploaded?

No. Formatting and minifying run in your browser.

Related tools