LocalExcelTool
Get started

JS / TS Formatter

Format JavaScript / TypeScript with Prettier.

Runs in your browserNo account neededFree

What is JS / TS Formatter

The JS/TS Formatter beautifies JavaScript and TypeScript code using Prettier (standalone build). Choose the babel parser for plain JS/JSX or the TypeScript parser for TS; output uses the standard style (semicolons, 2-space indent, double quotes). Prettier loads only when this tool runs, and your code never leaves the browser.

🔒 Everything runs in your browser. Nothing is uploaded.

What this tool actually does with your file

Where it runs
In your browser, on this page
Upload
None — the file never leaves your device
Offline
Works with the network disconnected

Prettier, loaded on demand

This runs the real Prettier standalone build with the Babel, ESTree and TypeScript plugins, imported dynamically so the page stays light until the tool is used. Input is capped at 200 KB, which covers ordinary source files but not generated bundles.

Supported inputs are JavaScript, TypeScript and JSX. Python, Go, Rust, CSS, SQL and HTML are not handled by these plugins and will either error or produce nonsense — a formatter is language-specific by nature, and Prettier's other parsers are separate packages.

Formatting is opinionated, and that is the point

Prettier rewrites quotes, semicolons, trailing commas, line wrapping and JSX attribute layout according to fixed rules. There is no configuration here, so the output matches Prettier's defaults rather than your project's .prettierrc.

That is fine for reading a snippet and wrong for committing to a repository with its own style. A one-off reformat of a file under a configured project generates a diff of every line, burying the change you actually made.

Where the output can differ semantically

Prettier preserves semantics by design, but it operates on parsed syntax — so a file that only works because of an obscure parsing quirk, or one relying on automatic semicolon insertion in a fragile spot, can change behaviour. TypeScript decorators and JSX pragma comments are the usual places to double-check.

If the code does not parse, nothing is formatted and you get a syntax error with a location. That error is often more useful than the formatting: it points at the exact token the runtime would have rejected.

How to use it

  1. 1.Paste your code (up to 200 KB)
  2. 2.Pick the parser (JS / TS)
  3. 3.Run and copy the formatted result

How JS / TS Formatter works under the hood

Formatters parse your input into a structure, then serialise it back with consistent indentation. That is why a formatter can also reveal a syntax error: if it cannot parse, it cannot print.

  1. 1

    Parse into a tree

    JSON goes through JSON.parse; YAML, XML, CSS and SQL use their own parsers. The parse either succeeds with a structure or fails at a line and column.

  2. 2

    Serialise with a fixed style

    Indentation width, key order and quoting are applied deterministically, so formatting the same input twice gives identical bytes.

  3. 3

    Show the error position

    When parsing fails, the message includes the position so the fix is obvious instead of guessed.

  4. Processing pipeline

Formatting is not validation

A formatter proves the document is syntactically parseable. It does not prove it is valid against a schema, and it does not check business rules. JSON with a duplicated key parses fine and silently keeps the last value.

What gets normalised

Comments are preserved in CSS and SQL but not in JSON, which has no comment syntax. YAML anchors may be expanded, and quote style may change. Keep the original when exact byte layout matters, such as signed payloads.

Verify it yourself

Formatting is deterministic and local — run it twice and compare.

  1. 1.Open DevTools on this page and switch to the Network tab
  2. 2.Keep the filter on Fetch/XHR and run the tool
  3. 3.Confirm no request carries your file — you should see only page assets and fonts

Frequently asked questions

Which syntax is supported?

The babel parser covers standard JavaScript and JSX; the TypeScript parser covers TS syntax. Experimental proposals may not parse.

Can I change the style?

This is a simple tool with a fixed standard style: semicolons on, 2-space indent, double quotes.

What this kind of conversion cannot keep

Formatters parse the input into a tree and print it back with consistent indentation. If the input is invalid, you get the parser's error position instead of a silently mangled file — malformed JSON stays malformed rather than being «repaired» into something that is no longer yours.

More in Format