JavaScript Minifier & Beautifier

Minify for compact size or beautify for readability — fully client-side for privacy.

Input & Options

Input: 0 B Output: 0 B Saving: —

Output

About this tool

This JavaScript Minifier & Beautifier is a simple, private way to clean up code. It runs entirely in your browser, so nothing you paste is uploaded or shared. Use it when you want to compress code for faster delivery, or when you need to format JavaScript to make it readable again.

Minifying JavaScript means removing parts of the file that humans use but browsers do not need, such as extra spaces, line breaks, and most comments. The goal is a smaller file size and quicker downloads. Beautifying is the opposite: it restores indentation and consistent spacing so the logic is easier to follow. This tool uses a careful tokenizer to avoid changing strings, regular-expression literals, or template literals, which helps preserve behavior while still shrinking or formatting the code.

To use the calculator, paste your code into the input box, choose the mode (Minify or Beautify), and set the options you prefer. Then run the tool and copy the result from the output area. For quick workflows, press Ctrl/Cmd + Enter to run Minify. Your last input is kept locally in the browser so you can pick up where you left off.

Options let you control how aggressive the formatting is. For example, you can remove comments to reduce size, keep license banners if you need to preserve legal headers, collapse whitespace for a tighter bundle, and insert safe semicolons in tricky edge cases where JavaScript’s automatic semicolon insertion could change meaning.

Typical uses

  • Compress a script before adding it to a website or embedding it in an HTML file.
  • Beautify a minified library to review or debug it during development.
  • Quickly format JavaScript snippets for documentation, tutorials, or code reviews.
  • Clean up pasted code so it is consistent before committing it to a project.

Whether you need a JavaScript compressor, a code formatter, or a quick JS beautifier, this tool helps you go from messy or bulky code to clean, readable, or smaller output in seconds.

FAQ

Does any code I paste get uploaded?

No. This tool runs entirely in your browser. Nothing is sent to any server.

Is this as aggressive as production minifiers like Terser?

It’s intentionally conservative for safety and privacy. It removes comments/whitespace and preserves behavior, but does not perform advanced AST transforms or mangling.

Will it keep license headers?

Yes — enable “Keep /*! ... */ license banners” to preserve license comments.

5 Fun Facts about Minifying JS

Regex vs division

Minifiers must tell /foo/ (a RegExp) from a/b (division). Heuristics look at the token before the slash to decide.

Slash detective

ASI isn’t magic

Automatic Semicolon Insertion works, but edge cases (return then newline then /regex/) can bite. Safe minifiers add semicolons in risky spots.

Return traps

Banner comments stay

Comments starting with /*! … */ are often licenses. Minifiers keep them when you enable the option, dropping the rest for size.

License friendly

Whitespace saves bytes twice

Less whitespace means smaller bundles before gzip/brotli, which makes compression ratios even better.

Compounding gains

Beautify to spot bugs

Pretty-printing can expose dangling braces or mismatched indentation that hide in minified blobs—great before code reviews.

Readable diffs

Explore more tools