TypeScript Formatter

Reflow TypeScript or JavaScript by brace depth for quick, readable indentation

Input

Formatted output

Nothing you paste here is ever uploaded — formatting happens entirely in your browser.

About this tool

This tool walks your TypeScript one brace, semicolon, and token at a time, pushing the indent in a level whenever it hits an opening curly brace and pulling it back out on the matching closing brace. It's meant for quickly cleaning up minified or inconsistently-indented snippets — interfaces, functions, classes — without installing a toolchain. It is not a real TypeScript parser: it doesn't understand generics with nested angle brackets, type-check anything, or reformat according to a style guide like Prettier would. Think of it as a fast first pass before a proper formatter, or a way to make a quick paste readable enough to review.

Is this a substitute for Prettier or the TypeScript compiler?

No. It only reflows whitespace around braces and semicolons for readability — it doesn't type-check your code, enforce a style guide, or catch syntax errors the way Prettier or `tsc` would. Use it for a quick visual cleanup, not as a build step.

Will it mess up template literals or arrow functions?

Because it's a simple token-based indenter rather than a full JS/TS parser, unusual constructs like multi-line template literals containing braces, or dense arrow-function chains, can sometimes format oddly. Straightforward interfaces, classes, and functions work best.

Does it work on plain JavaScript too?

Yes — since the formatter only reasons about braces and semicolons rather than TypeScript-specific syntax like types or generics, it works equally well on plain JavaScript.