Free JavaScript Formatter & Beautifier

Free JavaScript formatter: beautify minified or badly indented JS into readable code with js-beautify. Pick an indent size or strip comments and blank lines.

  • No upload, 100% private
  • Instant, in your browser
  • 100% free, no signup
Loading tool…
Read the complete guideHow to Unminify JavaScript and Make Sense of Compressed Code →

About the JavaScript Formatter tool

Minified bundles, code pasted from chat messages and scripts written without a formatter can be very hard to follow. This JavaScript formatter uses js-beautify to rebuild the layout of your code: every block is indented, statements go on their own lines, and spacing around operators and brackets is made consistent. It also works well for JSON, TypeScript-style syntax and modern ES features such as arrow functions, template literals, async/await and modules.

Pick 2 spaces, 4 spaces or tabs for indentation. The “Basic minify” switch is deliberately cautious: it removes comments, indentation, trailing spaces and blank lines, while keeping line breaks so JavaScript’s automatic semicolon insertion still works. Strings, template literals and regular expressions are preserved. It does not rename variables, join lines or remove dead code, so the result is smaller and cleaner but not as small as the output of a real minifier like Terser. The upside is that your code keeps behaving exactly as before.

Your code is processed in your browser only. It is never uploaded, which matters when you are working with proprietary scripts or keys embedded in code.

How to use JavaScript Formatter

  1. Paste code into the “JavaScript input” box, open a .js file with “Open file”, or click “Load sample”.
  2. Choose an “Indent size”: 2 spaces, 4 spaces or tab.
  3. Leave “Basic minify” off to beautify, or turn it on to strip comments and blank lines.
  4. Read the output, which updates automatically as you type.
  5. Click “Copy” or “Download” to save the result as a .js file.

Features

Unminify any script

Turns one-line bundles into properly indented, readable JavaScript.

Modern syntax

Handles arrow functions, classes, template literals, async/await and ES modules.

Configurable indent

Use 2 spaces, 4 spaces or tabs.

Honest basic minify

Strips comments, indentation and blank lines without risky transformations.

Private

Formatting runs locally with js-beautify and nothing is uploaded.

When to use it

  • Read a minified third-party script to understand what it does.
  • Tidy code snippets before pasting them into documentation or a ticket.
  • Format JSON or a JavaScript config object quickly without an IDE.
  • Remove comments and blank lines from a small script before sharing it.
  • Normalise indentation in legacy code before refactoring.

Frequently asked questions

Can this restore original variable names from minified code?

No. Beautifying restores layout only. Names shortened by a minifier, like a or t, cannot be recovered without a source map.

Is “Basic minify” safe to use on production code?

It only removes comments and whitespace at line starts and ends, and keeps every line break, so behaviour does not change. For best compression use a build tool such as Terser or esbuild.

Does it check my code for errors?

No. js-beautify formats code without running or validating it, so syntax errors are not reported. Unusual indentation in the output can hint at a missing bracket.

Does it support TypeScript or JSX?

Most TypeScript formats well because it is close to JavaScript. JSX is only partly supported and may not be laid out perfectly.

Is my code sent anywhere?

No. All processing happens in your browser tab.

Can I format JSON with this tool?

Yes, JSON is valid JavaScript and formats cleanly. For strict validation with error messages, the JSON Formatter or the JSON converters on this site are a better fit.

Related tools