Messy input
interface User{id:number;name:string};const get=<T>(x:T):T=>x;function area(r:number):number{return Math.PI*r*r}The TypeScript Formatter cleans up dense or minified TypeScript into well-structured, indented code. It formats type annotations, interfaces, generics, and decorators alongside ordinary statements, and normalizes spacing around operators and braces. Because it runs entirely in your browser, your source, including type definitions that may reveal internal data models, is never uploaded to any server.
TypeScript is a typed superset of JavaScript that adds static types, interfaces, enums, and generics, compiling down to plain JavaScript. The type layer makes large codebases safer and more self-documenting, but it also adds syntax that benefits from consistent formatting. Readable TypeScript makes complex generic signatures and union types easier to understand during review, and a shared style keeps diffs focused on real logic changes rather than whitespace.
The main file is the entry point for each run.
Use the Input panel to pipe standard input to your program when it needs data.
Run sends your code to a fresh hosted runtime and streams the result into the output panel.
Your draft stays in this browser, and Share creates a separate snapshot link.
interface User{id:number;name:string};const get=<T>(x:T):T=>x;function area(r:number):number{return Math.PI*r*r}interface User {
id: number;
name: string;
}
const get = <T>(x: T): T => x;
function area(r: number): number {
return Math.PI * r * r;
}class Box<T> {
constructor(private value: T) {}
get(): T {
return this.value;
}
}enum Status{Active,Inactive}type Result<T>={ok:true;value:T}|{ok:false;error:string};enum Status {
Active,
Inactive,
}
type Result<T> =
| { ok: true; value: T }
| { ok: false; error: string };async function fetchUser(id: number): Promise<User> {
const res = await fetch(`/api/users/${id}`);
const data: User = await res.json();
return data;
}@Component({
selector: 'app-root',
})
export class AppComponent {
@Input() title: string = '';
ngOnInit(): void {
console.log(this.title);
}
}type Options={readonly[K in keyof Config]?:Config[K]};function pick<T,K extends keyof T>(o:T,k:K):T[K]{return o[k]}type Options = {
readonly [K in keyof Config]?: Config[K];
};
function pick<T, K extends keyof T>(o: T, k: K): T[K] {
return o[k];
}The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Paste dense or minified TypeScript and get well-structured, indented code.
Type annotations, interfaces, generics and decorators are formatted cleanly.
Spacing around operators and braces is normalized alongside ordinary statements.
Complex generic signatures and union types become easier to read.
Interface and enum bodies are indented to reveal their members.
Keeps a shared style so diffs stay focused on logic, not whitespace.
Runs entirely in your browser; nothing is uploaded to any server.
Type definitions that hint at internal data models never leave your machine.
Copy the formatted code with one click for use in your project.
Ideal for tidying generated .d.ts files before review.
Output
Start typing to auto-process