Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

TypeScript Code Prettifier & Indenter

Paste minified or messy TypeScript to format with custom indentation and brace style, or minify for production

Your files never leave your browser
Input0 chars, 0 lines
Output0 chars, 0 lines
Ready·

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

Paste TS Code
→
Parse & Reformat
→
Formatted Output

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.

INPUT
interface User{id:number;name:string;email?:string;roles:Array<string>;}
OUTPUT
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.

INPUT
const Button:React.FC<{label:string;onClick:()=>void}>=({label,onClick})=>{return(<button onClick={onClick}>{label}</button>);}
OUTPUT
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.

INPUT
enum Status { Active = "active", Inactive = "inactive", Pending = "pending" }
OUTPUT
enum Status{Active="active",Inactive="inactive",Pending="pending"}

Who Uses This

👨‍💻 Frontend Developers

Cleaning up component files and shared type definitions before code review.

🎓 Students

Making sense of minified TypeScript examples from textbooks or Stack Overflow answers.

🔧 DevOps Engineers

Minifying TypeScript config files and utility scripts for smaller deployment bundles.

📝 Technical Writers

Formatting code snippets for documentation so they are consistent and readable.

Common Mistakes

Pasting JavaScript and expecting TS-specific formatting

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.

Forgetting to check brace style before formatting

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.

Minifying code that still has syntax errors

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

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.

Share: