Developer Tools

JavaScript Formatter

Turn a wall of minified JavaScript into properly indented code you can read and debug. Pick your indent and brace style; the logic is left untouched.

  • Runs in your browser
  • No sign-up
  • Free to use

How to use JavaScript Formatter

  1. Paste JavaScript into the input editor, or open a .js file.
  2. Choose the indentation and where opening braces should go.
  3. Select Format JavaScript.
  4. Copy the formatted code or download it.

JavaScript Formatter features

Unminifies bundled code

Restores line breaks and indentation to single-line production scripts.

Brace style options

Keep opening braces on the same line, or move them to their own line.

Modern syntax support

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

Method chains kept readable

Optionally break long chained calls onto separate lines.

Comments preserved

Line and block comments stay where they are.

Never executed, never uploaded

The code is treated as text and formatted in your browser.

When to use JavaScript Formatter

  • Reading a minified third-party script to see what it does.
  • Debugging production code when source maps are not available.
  • Tidying a snippet copied from a forum or documentation.
  • Normalising style before pasting code into a review or a bug report.

JavaScript Formatter FAQ

Can it restore original variable names?

No. Minifiers shorten names to single letters and that information is gone. The formatter restores structure and whitespace, which is usually enough to follow the logic.

Does it change how the code behaves?

No. Only whitespace and line breaks are changed. One caveat applies to any formatter: code that relies on automatic semicolon insertion in unusual ways is kept as written, not corrected.

Does it check for syntax errors?

No. It is tolerant and formats whatever it can, so it is not a substitute for a linter or for running the code.

Does it work with TypeScript or JSX?

Most TypeScript and JSX formats acceptably because the syntax is close to JavaScript, but generics and complex JSX can be indented imperfectly. Use a dedicated tool for those in a build pipeline.

Can it format JSON?

Yes, JSON is valid JavaScript syntax. For validation and key sorting, the JSON Formatter is a better fit.

Minified code and how to read it

JavaScript sent to browsers is usually minified: whitespace and comments are stripped, local names are shortened, and statements are joined with commas and ternaries to save bytes. The result runs identically but is unreadable. When something breaks in production, or you want to understand what a third-party script does, the first step is to put the structure back.

A beautifier tokenises the source and re-emits it with one statement per line and indentation that reflects block depth. Combined with your browser's developer tools, which can also pretty-print and set breakpoints, this is often sufficient to trace a problem even without the original source.

Other useful tools