Home/Dev Tools/TypeScript Minifier

TypeScript Minifier

Minify

Minify TypeScript for production. Strip types and compress with Terser.

Options
Input
Loading editor…
Output
Loading editor…
✨ AI Code Explanation
Mode

What Is TypeScript Minification?

TypeScript minification compiles your .ts source to JavaScript and then compresses it — stripping type annotations, shortening variable names, removing whitespace and comments — to produce the smallest possible output for production. This tool uses Terser with TypeScript parser support, running entirely in your browser. The output is plain JavaScript ready to deploy.

What Happens to TypeScript Types During Minification?

TypeScript type annotations (: string, interface, type, generics, as const) are compile-time constructs — they do not exist at runtime. Terser's TypeScript parser strips all type information as part of the minification process, producing valid JavaScript. This is the same process your bundler (Webpack, Vite, esbuild) performs internally.

How to Minify TypeScript Online

  1. Paste your TypeScript source code into the left editor pane (or click Load Sample).
  2. Choose your options: Mangle names, Drop console, Keep comments.
  3. Click Minify — the compressed JavaScript output appears in the right pane.
  4. The stats badge shows original size, minified size, and percentage saved.
  5. Click Copy to copy the output, or Download to save as minified.js.
  6. Use Explain with AI to get a plain-English description of what the original code does.

Minification Options Explained

  • Mangle names (default: on) — renames local variables, function parameters, and class members to short single-character names. The biggest contributor to size savings. Safe for self-contained TypeScript modules; disable if your code relies on Function.name or reflection.
  • Drop console (default: off) — removes all console.log(), console.error(), console.warn() and similar calls. Use for production builds where debug output is not needed.
  • Keep comments (default: off) — preserves comments in the output. Useful for retaining license headers or copyright notices (e.g. /*! MIT License */).

TypeScript Minifier vs JavaScript Minifier

The key difference is the parser. This tool uses Terser's TypeScript parser which understands and strips type annotations before compressing. If you run plain JavaScript through the JavaScript Minifier, TypeScript syntax like const x: number = 1 will throw a parse error. Always use the correct tool for your file type.

Common TypeScript Minification Errors

  • SyntaxError: Unexpected token — your TypeScript has a syntax error. Fix it first, then minify.
  • Output breaks at runtime — mangling can break code that uses eval() with variable names or reads Function.name. Disable Mangle names.
  • Decorator errors — legacy experimental decorators may not parse correctly. Try formatting the file in your local toolchain instead.
  • Output is already minified — if input is minified, Saved% will be near 0%. This is expected.

Related Tools

Is My Code Sent to a Server?

No — all minification runs entirely in your browser using Terser's browser build. Your code never leaves your machine. No account required, no rate limits on minification.