Skip to content

Format or minify JavaScript source code while preserving strings and comments safely without executing user code.

Loading tool

About JavaScript Beautify / Minify

Format JavaScript with 2, 4 or 8 spaces or tabs using js-beautify, or strip comments and whitespace for a smaller file. The minify mode is a conservative whitespace and comment stripper, not a full minifier: it understands strings, template literals and regex literals, keeps /*! license */ comments and keeps line breaks where automatic semicolon insertion could matter, but never renames identifiers or removes dead code. Code is only processed as text and is never executed.

Common uses

  • Make a minified bundle or third-party script readable while debugging.
  • Clean up inconsistent indentation in a snippet before sharing it.
  • Inspect a suspicious script safely, since it is not run.
  • Remove comments and whitespace from a small snippet for a bookmarklet or inline <script>.

FAQ

Can beautifying recover the original variable names of minified code?
No. Beautifying restores indentation and line breaks, but names shortened by a minifier such as Terser are not recoverable without a source map.
What is the difference between minifying and mangling?
Minifying removes whitespace and comments; mangling renames variables to shorter names. Production tools like Terser or esbuild do both, while this tool only does the former.