JavaScript Beautifier & Minifier

Format messy JavaScript with custom indentation and brace styles, or minify to shrink file size. ES6+ supported. Runs entirely in your browser โ€” your code never leaves your device.

Beautify ยท Minify ยท ES6+ ยท client-side
Input 0 chars ยท 0 lines
Output 0 chars ยท 0 lines

How to Beautify & Minify JavaScript

How to use this tool

Paste your JavaScript into the input panel, select Beautify or Minify from the mode tabs, and the result appears instantly. Adjust options like indent size, brace style, and newline handling before processing. Click Copy Output to copy to clipboard or Download .js to save the file.

Beautify options explained

  • Brace Style โ€” Collapse keeps { on the same line (K&R / standard JS). Expand puts { on its own line (Allman style). End-expand is a hybrid where else and catch get fresh lines.
  • Preserve Newlines โ€” keeps blank lines from the original where they exist. Useful for code that uses spacing as logical grouping.
  • JSLint-happy โ€” matches the style enforced by Douglas Crockford's JSLint. Function expressions get a space before (, among other tweaks.
  • Unescape Strings โ€” converts \xNN and \uNNNN escapes back to their literal characters where safe.

Minify options explained

  • Keep /*! license */ โ€” preserves comments starting with /*!, the convention used by most libraries to mark MIT/Apache copyright headers that must remain in distributed code.
  • Strip last semicolon โ€” removes the final ; before }. Saves a byte but makes diffs noisier, so it's off by default.

The minifier is intentionally conservative โ€” it removes whitespace and comments only. It does not rename variables, mangle properties, or perform AST-level dead-code elimination. For aggressive optimization use terser or esbuild in your build pipeline.

Powered by js-beautify

The beautifier is powered by js-beautify, the same library used by VS Code, Sublime Text, Atom, and most popular online formatters. Everything runs locally in your browser โ€” no upload step, no server round-trip, and no rate limit. Paste a 500 KB minified bundle and it formats in milliseconds.

FAQ

Is my JavaScript code sent to a server?

No. All beautification and minification happens entirely in your browser using js-beautify loaded from a CDN. Your code never leaves your device.

What's the difference between beautifying and minifying?

Beautifying formats code with proper indentation and line breaks for human readability. Minifying removes whitespace, comments, and unnecessary characters to reduce file size for production deployment.

Does the minifier rename variables?

No. This tool performs whitespace and comment removal only. It does not rename variables, mangle identifiers, or perform AST-level optimizations. For that level of compression use Terser, UglifyJS, or esbuild in a build pipeline.

Can it handle ES6+ syntax?

Yes. The beautifier supports modern JavaScript including arrow functions, template literals, async/await, classes, destructuring, spread/rest, optional chaining, and nullish coalescing.

What brace style options are available?

Three styles: Collapse (opening brace on same line as the statement), Expand (opening brace on a new line), and End-Expand (opening on same line, but else and catch get new lines).

Related Tools