← All tools
// CODE

JS Prettifier online

Format, indent and beautify JavaScript code — or minify it for production.

JavaScript Prettifier / Formatter logo
by
CHUNKY
MUNSTER
JS INPUT0 CHARS
FORMATTED OUTPUT0 CHARS

About JS Prettifier

This tool uses the JS Beautify library to format JavaScript with consistent indentation. Use it on minified code to make it readable, or on your own code before a code review. The minify option is a basic whitespace stripper — for production builds use a bundler like Webpack or esbuild.

How to Use the JavaScript Prettifier

  1. Choose Prettify or Minify with the tab buttons.
  2. Paste your JavaScript into the input panel.
  3. Click Prettify JS / Minify JS — the result appears below.
  4. Copy takes the output to your clipboard.

JavaScript Prettifier wraps js-beautify 1.15.1, the same library that backs VS Code's Beautify extension and beautifier.io. Paste minified or compressed JavaScript and it returns 2-space-indented, readable code with consistent spacing around operators, brackets and keywords. Modern syntax — arrow functions, async/await, optional chaining, classes, template literals — is recognised and indented correctly.

How the JavaScript Prettifier Works

The Minify mode is intentionally simple: it strips // and /* */ comments and collapses runs of whitespace. That is enough for sharing a snippet inline or a quick obfuscation pass, but it does not rename variables or eliminate dead code. For production bundles use a real minifier such as esbuild, Terser or SWC. Everything runs in the browser; the source never leaves the page.

Frequently Asked Questions

Which formatter does this use under the hood?

js-beautify 1.15.1 loaded from cdnjs. It is the same engine that powers most VS Code 'Beautify' extensions and beautifier.io, so the output should match those tools byte-for-byte at the same settings.

Is the Minify option safe for production?

Not really. It strips // and /* */ comments and collapses whitespace, but it does NOT rename variables, dead-code-eliminate, or fix automatic-semicolon-insertion edge cases. For real builds use esbuild, Terser or SWC.

Will it format JSX or TypeScript?

JSX often parses but indentation can be off because js-beautify treats < as an operator. TypeScript type annotations frequently confuse the formatter. For TS/TSX files use Prettier or the TypeScript language server formatter.

Does prettifying change the meaning of my code?

No — only whitespace and line breaks are added. The exception is automatic-semicolon-insertion: code that relies on ASI in an unusual way (a return on its own line, for example) keeps the same parse tree, but reading order may surprise you.

Explore the full suite of Code tools and 290+ other free utilities at Chunky Munster.