jsonecho

TypeScript Formatter

Format TypeScript code, with generics, decorators, enums and type annotations.

Loading the tool...

How to use TypeScript Formatter

  1. Paste your code. The formatter engine loads in a moment the first time.
  2. Adjust the options if you need to.
  3. Copy the formatted result.

About TypeScript Formatter

This formatter parses TypeScript with the real TypeScript parser, so interfaces, generics, enums, decorators, abstract classes and the latest syntax are handled, not just guessed at. The code is printed again from scratch, with consistent spacing and line breaks.

Choose single quotes and the semicolon style to match your project. Long lines are wrapped at 80 characters.

Frequently asked questions

Does it check types?

No. It checks syntax only. A type error will not stop the formatting.

Is the output the same as Prettier?

The tool uses the Prettier engine and its defaults, so yes, apart from the options you change here.

Does it support TSX?

Paste JSX inside TypeScript and it is formatted too. For plain React code, the Babel Formatter is the better fit.

Why did the first run take a second?

The formatting engine for this language is downloaded the first time you use it, then cached by your browser. After that, formatting is instant and nothing leaves your machine.

More in Code Formatters

All tools →