Skip to content

JavaScript Formatter

Re-indent JavaScript, with strings and regular expressions left alone.

This fixes indentation, statement breaks and spacing, and leaves everything else where you put it. A full reprinter needs a parser and rewrites code nobody asked it to touch.

Quick Tool Overview

The JavaScript Formatter works from tokens rather than patterns, which is what lets it tell a division from the start of a regular expression — the one genuinely hard part of reading JavaScript, and the one that mangles code when it goes wrong.

What it does
Re-indents JavaScript and normalises spacing
You give it
Minified or inconsistently formatted JS
You get back
Readable code with everything else left alone
Best for
Making a bundle or a snippet legible
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the JavaScript Formatter

Paste JavaScript and get it back indented: blocks nested properly, statements on their own lines, and spacing normalised around operators and punctuation. It is the fastest way to make a minified bundle or a one-line snippet readable.

The formatter works from tokens rather than patterns, which is what makes it safe. The genuinely hard problem in JavaScript is telling a division from the start of a regular expression — they look identical and only the preceding token decides — and getting that wrong mangles code silently. Strings, template literals with nested expressions, and both comment styles are all preserved byte for byte.

Key features of the JavaScript Formatter

Regular expressions survive

A regex and a division look identical and only the preceding token decides. The formatter tracks it, so neither is corrupted.

Strings kept byte for byte

Including template literals with nested expressions, which can themselves contain backticks.

Deliberately conservative

It fixes indentation, statement breaks and spacing, and leaves your choices alone. A full reprinter rewrites code nobody asked it to touch.

Modern syntax handled

Arrow functions, optional chaining, nullish coalescing and the logical assignment operators all tokenise correctly.

Statistics to check against

Token, string, comment and regex counts, so you can confirm nothing was lost in the round trip.

How to use the JavaScript Formatter

  1. 1

    Paste your JavaScript

    Minified code, a snippet, or something inconsistently formatted.

  2. 2

    Choose the indentation

    Two spaces, four spaces or a tab.

  3. 3

    Check the statistics

    Token, string, comment and function counts confirm nothing was lost.

  4. 4

    Copy the result

    Take it to your clipboard or download it as a .js file.

Frequently asked questions

No, and deliberately. It fixes indentation, statement breaks and spacing, and leaves everything else where you put it. A full reprinter needs a parser and rewrites code nobody asked it to touch.

Reviews of the JavaScript Formatter

What people who use the JavaScript Formatter think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the JavaScript Formatter. It takes half a minute and no account.

Write the first review

More developer tools