JavaScript Formatter

  • Free forever
  • No sign-up
  • Runs in your browser
Processed on your device

Make minified or messy JavaScript readable again, with proper indentation and line breaks.

About JavaScript Formatter

Unpicks minified or badly spaced JavaScript into properly indented code with sensible line breaks, so you can follow what a script does, debug a third-party file or review a snippet someone sent you. Choose the indent and wrap width, and pick a brace style: same line, own line, or else and catch on their own line. Blank lines you left are kept, up to two in a row.

How to use JavaScript Formatter

  1. Paste your minified or messy JavaScript into the box.
  2. Choose the Indent, whether to Wrap long lines, and the Brace style you prefer.
  3. Click Format JavaScript; the readable version replaces the original in the same box.
  4. Click Copy to use the formatted code, or Clear to start again.

How your data is handled

The code is formatted in your browser with the js-beautify library, loaded from our own site the first time. Your scripts aren't uploaded, run or stored.

How SAA Tool works · Privacy Center

Limits and accuracy

  • JSX isn't supported: its tags get split up with extra spaces, which breaks the code.
  • Syntax errors aren't reported; broken or unfinished code is laid out as well as it can be.
  • Packed or obfuscated code is only re-indented, not unpacked or given meaningful names.

Questions and answers

Can it restore the original variable names?

No. Formatting adds indentation and line breaks, but names a minifier has shortened, such as a or t, can't be recovered. The code still becomes much easier to follow.

Which brace style should I choose?

Same line (K&R) keeps the opening brace at the end of the line and is the most common in JavaScript. Own line (Allman) puts every brace on its own line. End on own line moves else and catch below the closing brace.

Is my code uploaded?

No. It's formatted in your browser, so private or unreleased scripts aren't sent to SAA Tool or saved anywhere.

Do I need to sign up?

No. JavaScript Formatter is free with no sign-up, no login and no daily limit, and there's nothing to install. It works on a phone as well as a PC.

Does it work for React and modern JavaScript?

Yes. It formats ES2020+ syntax, including arrow functions, classes, async/await and template strings. For JSX, format the plain JavaScript parts; a project formatter such as Prettier handles the markup better.

Report a problem with this tool