About the TypeScript Formatter
This page uses Prettier with the typescript parser (built on @typescript-eslint/typescript-estree), so it accepts everything the TypeScript compiler parses: interfaces, type aliases, generics with defaults and constraints, enums, satisfies, decorators, abstract classes, parameter properties, non-null assertions and TSX.
Long union types are broken one member per line with a leading |, long generic parameter lists and function signatures wrap at the print width, and object types use the same bracket spacing as object literals. The options match .prettierrc keys (tabWidth, useTabs, printWidth, semi, singleQuote), so the result matches what your editor's format-on-save produces with the same settings.
Formatting is purely syntactic: the tool does not type-check, so code with type errors still formats as long as it parses. Syntax errors — say, a missing > in a generic — are reported with line and column. Everything runs in your browser; the TypeScript parser is about 900 KB and loads once on first use.
How to use it
- Paste TypeScript or TSX code.
- Set indentation, print width, semicolons and quote style.
- Let the TypeScript parser load on first use.
- Copy or download the formatted code.
Frequently asked questions
Does it check types?
tsc --noEmit for type checking.