TypeScript Formatter

How it works
Indent
Valid TypeScript

Input TypeScript

No problems found. This is valid TypeScript.

About TypeScript Formatter

Tidy up TypeScript snippets from reviews, docs or chat without opening an editor. The formatter understands type annotations, interfaces, generics, enums and decorators, and lays them out in Prettier’s familiar style.

It formats code; it does not type-check it. Syntax errors are reported with their position, but type errors are left for your compiler.

How to use it

  1. Paste TypeScript into the Input panel, or Open a .ts or .tsx file.
  2. Pick an indent of 2, 4 or Tab.
  3. Check the Problems panel for syntax errors.
  4. Copy the formatted code or Download it.

Frequently asked questions

Does it report type errors?

No. Only syntax errors are reported. Use the TypeScript compiler to check types.

Does it support TSX?

Yes. Code with JSX inside TypeScript is supported.

Is the code kept private?

Yes. Formatting runs in your browser and nothing is uploaded.

Related tools