TypeScript Minifier & Beautifier

Format or compress TypeScript — types, generics and decorators all preserved exactly. This formats your TypeScript; it does not transpile it to JavaScript.

Only whitespace and comments are ever changed. No TypeScript token is renamed, reordered or removed, so the output cannot behave differently from your input. That also means the size reduction is smaller than tools which rewrite your code .

Indent
Off by default: conditional comments and build markers look like ordinary comments, so removing them is your call. Note SQL comments can carry real meaning (query hints in some databases live in comments), so check before stripping. A /*! banner comment is always kept, the usual convention for a licence header.

Drop a TypeScript file here

or or paste below

Up to 4 MB · nothing uploaded

{{ inBytes }}
{{ outBytes }}
{{ status }}

{{ commentWarning }}

Your TypeScript is tokenized and reformatted entirely in your browser. Nothing you paste or drop is ever uploaded to a server.

Your types come out exactly as they went in

This is a formatter, not a compiler. Type annotations, interfaces, enums, generics and decorators are all preserved character for character — nothing is transpiled, downlevelled or type-stripped. If you want JavaScript out the other end, that is tsc's job and a very different tool.

The generic ambiguity that never has to be solved

Whether < opens a generic parameter list or means less-than is genuinely ambiguous in TypeScript, and resolving it is one of the harder parts of writing a TS parser. A formatter that only moves whitespace sidesteps the question entirely: f<number>(1) and a < b are handled identically and both come out correct. That is a real dividend of the whitespace-only design rather than a shortcut.

One case that does need care

Nested generics ending in >>, as in Array<Map<string, number>> = []. Those two closing brackets tokenize as the right-shift operator, and removing the space before = would fuse them into >>= — a completely different operator. That fusion is prevented explicitly, and the test that caught it checks every operator pair rather than just this one.

Why the saving is smaller than esbuild's or Terser's

Because those strip your types, rename identifiers and remove dead code. That is where most of their compression comes from, and also where a bug in them would silently change behaviour. This tool removes only formatting, so it compresses less and cannot change what your code does.

Plain JavaScript instead?

Use the JavaScript Minifier & Beautifier.

Does this transpile TypeScript to JavaScript?

No. It formats TypeScript source and leaves the types in place. Type annotations, interfaces, enums, generics and decorators all come out exactly as they went in, because only whitespace and comments are ever changed. If you want types removed and modern syntax downlevelled, that is a compiler's job.

Does it get generics right?

Yes, and interestingly it never has to resolve the hard part. Whether < opens a generic or means less-than is genuinely ambiguous in TypeScript, but a formatter that only moves whitespace does not need to know: both cases are handled identically. The one case that does need care is nested generics ending in >>, where removing the following space would fuse it into the >>= operator — that is prevented explicitly.

Are decorators preserved?

Yes. @Component, @Injectable and any other decorator, including ones with object arguments spanning several lines, are formatted like ordinary code and never altered.

Why is the size reduction smaller than a real bundler's?

Because a bundler renames identifiers, removes dead code and strips your types entirely — that is where most of its compression comes from, and also where a bug in it could change behaviour. This tool only removes formatting, so it compresses less and cannot change what your code does.

Is my source uploaded anywhere?

No. Everything runs in your browser, which matters since TypeScript source is rarely public.