TypeScript Beautifier
Format TypeScript with the same engine your editor uses.
TypeScript Beautifier – Format TS Code Online
The TypeScript beautifier formats .ts and .tsx code with Prettier's official TypeScript parser. Paste a cramped class, a generated API client, or a snippet from a code review, and get readable, consistently formatted TypeScript back within milliseconds.
Features
- Full TypeScript syntax: interfaces, type aliases, generics, enums, abstract classes, decorators,
satisfies, andas const. - Choose indentation (2 spaces, 4 spaces, or tabs) and a line width of 80, 100, or 120.
- Toggle semicolons, single quotes, and trailing commas to match your style guide.
- Syntax errors are reported with line and column.
- Open a file, copy the result, or download it as
formatted.ts.
How long types are wrapped
Union types, function signatures, and generic constraints are often written on one long line. Prettier breaks them only when they exceed the line width: union members go on separate lines with a leading |, parameters get one line each, and object types are expanded property by property. Short types stay on one line, so the output does not explode vertically.
Formatting does not type-check
The beautifier checks that your code is syntactically valid TypeScript, but it does not run the compiler. Type errors such as assigning a string to a number are not reported — use tsc or your editor for that. On the other hand, this means you can format snippets that reference types defined elsewhere without any setup.
Typical uses
Clean up code pasted from documentation, normalize generated SDKs before committing them, prepare examples for blog posts, or quickly format a file when you are away from your usual editor. For plain JavaScript use the JavaScript Beautifier; for Angular components and templates, the Angular Formatter has both modes in one page. React projects written in TSX can also use the React Formatter.
Frequently Asked Questions
Does it support TSX files?
Yes. The TypeScript parser understands JSX inside .tsx files, so React components with typed props are formatted correctly.
Will it report type errors?
No. Formatting only needs a syntax tree, not type information. Code with type errors is formatted as long as it parses; run tsc to find type problems.
Are decorators supported?
Yes, both the legacy experimentalDecorators style used by Angular and NestJS and the standard ECMAScript decorators are parsed and kept in place.
Can I format a .d.ts declaration file?
Yes. Declaration files are ordinary TypeScript syntax, so declare statements, namespaces, and overloads are formatted like any other code.