Skip to content

JavaScript Formatter

Beautify JavaScript with Prettier, right in your browser.

Indent

Quotes

Everything runs in your browser. Nothing is uploaded.

More Developer Tools

All tools

How to use the JavaScript formatter

Three steps, all in your browser.

  1. 1

    Paste your input

    Type or paste your code or data. Press Sample to try an example.

  2. 2

    Pick the style

    Choose indentation or options. The result updates as you type.

  3. 3

    Copy the result

    Copy the output in one click. Nothing is saved or sent anywhere.

JavaScript Formatter: what to know

The JavaScript formatter runs Prettier in your browser to rewrite code with consistent indentation, line breaks, quotes and semicolons. It understands modern JavaScript, including modules, classes, async/await, optional chaining and JSX, can switch to TypeScript (TSX), and reports a syntax error with its location if the code can't be parsed.

It's also a quick way to make minified code readable. Indentation and line breaks come back, so you can follow the control flow, but anything the minifier threw away stays gone: short variable names like a and b aren't restored and comments don't reappear. For that you need the original source or its source map.

Prettier is opinionated on purpose. Instead of dozens of style options it applies one consistent style, which is why many teams run it on every save. Running it here with the default options gives the same result as Prettier's defaults in your editor.

Popular uses

  • Reading minified scripts from a website or package
  • Tidying snippets before sharing them in a pull request or issue
  • Formatting code copied from a chat, email or PDF
  • Checking code for syntax errors quickly

Tips for the best result

  • If code from a PDF or chat won't parse, look for smart quotes or non-breaking spaces that came along with it.
  • Type annotations only parse in TypeScript mode; switch the language if you see an error at a colon or angle bracket.
  • Use the JavaScript minifier for the opposite direction.

Read how JustYourDev works and our privacy details. Code, data and files you use here are processed in your browser and are never sent to our server.

Frequently asked questions

It can restore indentation and line breaks, which makes minified code readable again. It can't bring back original variable names or comments that the minifier removed; for that you need the source map.

Yes. Prettier understands current JavaScript, including modules, classes, optional chaining, async/await and JSX, and you can switch the language to TypeScript (TSX). If your code has a syntax error, the error message points at the line.

No. Every tool runs in your browser, so your code, tokens, keys and files are processed on your device and are not sent to our server or stored. Reloading or closing the page clears them.

Yes. Every tool is free with no sign-up and no limits on use. Clearly labeled ads keep it that way.

Yes. The tools work in any modern browser on phones, tablets and computers, though large files and long code are easier to handle on a computer.