Skip to content

JavaScript Formatter

Format JavaScript with Prettier. Fixes indents, spaces, quotes and line breaks in one click. Free online JS beautifier in your browser.

Something not working? Report a problem

What is the JavaScript Formatter?

Paste any JavaScript, even one long line from a minified file, and get tidy code with consistent spacing and indents. It understands modern JavaScript, JSX and ES modules.

Pick the indent size, line width, semicolons and quote style. If the code has a syntax error, you see the line and a short note.

How to use it

  1. Paste your JavaScript in the left box.
  2. The clean version shows on the right.
  3. Copy it or save it as a file.

Why people like this tool

Prettier powered

The same formatter many teams use.

Fast and private

Runs in your browser, nothing is sent.

Shows the error

Tells you where the code is broken.

Your style

Choose indent size and line width.

What it fixes

  • Code squashed on one line gets one statement per line.
  • Mixed tabs and spaces become one indent size, which you choose.
  • Long lines are wrapped at the line width you set.
  • Quotes can be made single or double in one step.

Formatting follows the popular Prettier style, which many teams use, so the result looks familiar in most projects.

Tips

  • If the tool shows an error, there is a real mistake in the code, like a missing bracket. The error message tells you the line.
  • Formatting does not change what your code does. Only spacing and line breaks change.
  • To read code from a live website, copy it from the browser tools, paste it here and format it.

How it works, in one picture

Infographic: how to use the JavaScript Formatter in 3 easy steps: Add your text, Choose your options and Copy the result. You get: Prettier powered, Fast and private, Shows the error and Your style.

Frequently asked questions

How do I beautify JavaScript?
Paste your code in the left box. The formatted version shows on the right.
Does it work with JSX and ES modules?
Yes. Import and export, async code, classes and JSX all work.
Can it unminify a minified file?
It adds line breaks and indents, but the short variable names stay short. It cannot bring back the original names.
Does formatting change how my JavaScript runs?
No. It only changes spaces, line breaks and quote style. The code does the same thing as before.

You may also like