TypeScript Code Prettifier & Indenter
Paste minified or messy TypeScript to format with custom indentation and brace style, or minify for production
Paste messy or minified TypeScript, pick your indent size and brace style, and get cleanly formatted code back in one click — interfaces, generics, enums, and all. Flip to minify mode when you need to strip it down for production. And everything runs in your browser. Nothing gets uploaded.
How It Works
The formatter parses your TypeScript token by token — tracking braces, brackets, strings, template literals, and comments. It rebuilds the indentation tree from scratch based on your settings. TypeScript keywords like interface, type, and enum get proper spacing. The minifier does the reverse: strips whitespace, kills comments, and collapses everything into the smallest valid output.
Examples
Fixing a Minified Interface
Someone pasted a minified type definition into a PR comment. You need to actually read it.
interface User{id:number;name:string;email?:string;roles:Array<string>;}
interface User {
id: number;
name: string;
email?: string;
roles: Array<string>;
}
Cleaning Up a Messy React Component
Copy-pasted from a tutorial where the indentation got mangled during formatting.
const Button:React.FC<{label:string;onClick:()=>void}>=({label,onClick})=>{return(<button onClick={onClick}>{label}</button>);}
const Button: React.FC<{
label: string;
onClick: () => void
}> = ({label, onClick}) => {
return (
<button onClick={onClick}>
{label}
</button>
);
}
Minifying an Enum for a Config File
Shrinking a verbose enum definition before embedding it in a JSON config payload.
enum Status {
Active = "active",
Inactive = "inactive",
Pending = "pending"
}
enum Status{Active="active",Inactive="inactive",Pending="pending"}
Who Uses This
Cleaning up component files and shared type definitions before code review.
Making sense of minified TypeScript examples from textbooks or Stack Overflow answers.
Minifying TypeScript config files and utility scripts for smaller deployment bundles.
Formatting code snippets for documentation so they are consistent and readable.
Common Mistakes
Plain JS works fine here — it is valid TypeScript. But the formatter can only restructure what you give it. It won't add type annotations or generics that aren't already there.
The default "collapse" style puts opening braces on the same line. If your team uses "expand" style (opening brace on its own line), you will format everything and then have to redo it. Pick your brace style first.
Minification strips whitespace but does not validate your TypeScript. If there is a missing bracket or a stray semicolon, the minified output will still be broken — just harder to debug. Format first to spot issues, then minify.
Technical Details
- Processing: 100% client-side — nothing uploaded
- Browser Support: Chrome, Firefox, Safari, Edge
- Language Support: TypeScript (.ts), TSX (.tsx), and plain JavaScript
- Output Options: Beautify (2 or 4 space indent, 3 brace styles) or Minify
- Syntax Highlighting: Keywords, strings, comments, numbers, operators
Frequently Asked Questions
What is the difference between a TypeScript formatter and a linter?
A formatter fixes how your code looks — indentation, spacing, line breaks. A linter like ESLint checks what your code does — unused variables, potential bugs, bad patterns. This tool is a formatter only. It won't tell you about logic problems, but it will make your code readable in seconds.
Can I format .tsx files here?
Yes. TSX (TypeScript with JSX) gets formatted the same way. The tool handles angle brackets in JSX without confusing them for generics. One thing to watch: deeply nested JSX might not indent exactly how your IDE would, since this is a general-purpose formatter rather than a React-specific one.
Is this the same as Prettier for TypeScript?
Similar idea, different tool. Prettier builds a full AST and reprints your code from scratch. This formatter works at the token level — faster, runs entirely in your browser with zero dependencies. For quick reformatting jobs, it does the trick without needing a Node.js install or config file.
Does minification break TypeScript type checking?
No. Minification only removes whitespace and comments — it does not rename variables or change the structure. The TypeScript compiler will still type-check minified code the same way. That said, minified TS is mostly useful for embedding in configs or reducing file size; you would not normally commit minified source code.
Is my code safe? Does it get sent anywhere?
Everything runs in your browser. Your code is not uploaded, not logged, not stored anywhere. The page does not even make network requests when you format — you can turn off your internet connection and it still works. Good for proprietary codebases where you can't paste into random websites.