Minify TypeScript

Remove comments and redundant whitespace from TypeScript for a compact preview.

freeworks offlinenothing uploaded
ToolTypeScript Minifier
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Comments and unnecessary spacing are removed while strings, template literals, and TypeScript syntax are protected. The result is compact source-like text rather than type-aware compiler output.

  • This quick pass estimates size without a compiler.
  • Syntax is preserved instead of transforming types.

Worked example

Minify TypeScript
Remove types and whitespace from TypeScript code
Input
											function add(a: number, b: number): number {
  return a + b;
}
										
Output
												function add(a,b){return a+b;}
											

When to use this

Bundle experiments, playground snippets, and generated-file reviews minify TypeScript.

Edge cases

  • Angle-bracket assertions are not HTML.
  • Template literals contain expressions and embedded newlines.
  • Decorators and newer syntax can remain unchanged.

References