Tool Logo

JavaScript Formatter

Turn minified or messy JavaScript into clean, consistently formatted code.

0 characters

Loading tool…

How to use the javascript formatter

The formatter runs Prettier, the code formatter used by most JavaScript projects, in your browser. It parses your code and prints it again with consistent indentation, line breaks, spacing and quotes, so even a one-line minified file becomes readable. It supports modern JavaScript and JSX; if the code has a syntax error you'll see where it is.

  1. Paste your JavaScript or upload a .js file.
  2. Choose indentation, line width and single or double quotes.
  3. Copy the formatted code.

When to use it

  • Minified code

    Make a minified script readable to debug or learn from it.

  • Consistent style

    Format snippets the same way as a Prettier-based project.

  • Sharing code

    Clean up code before pasting it into docs, tickets or answers.

Frequently asked questions

Does formatting change what my code does?

No. Prettier only changes layout: indentation, line breaks, spacing, quotes and optional parentheses. The program behaves exactly the same.

Does it support JSX and modern JavaScript?

Yes: classes, async/await, optional chaining, modules and JSX. TypeScript isn't supported on this page.

Can it un-minify code?

It restores readable layout, but minified variable names like a and b stay short, because the original names are gone.

What if my code has a syntax error?

Prettier needs valid code to format it, so you'll see the error and its line instead. The JavaScript Validator can help you track it down.

Is my code uploaded?

No. Everything runs in your browser; nothing you paste or upload is sent to our servers.