TypeScript Playground (Offline)

Compile TypeScript to JavaScript in your browser — no server, no tsc install

Ad placeholder (leaderboard)

A TypeScript to JavaScript transpiler strips the type layer from your code so it can run anywhere JavaScript runs. TypeScript types exist only at compile time; the runtime sees plain JavaScript. This offline playground performs that conversion — called type erasure — in your browser, with no tsc install and no upload, so you can quickly see what your code becomes at runtime.

How it works

Modern TypeScript build tools (esbuild, swc, Babel’s TS preset, and tsc under isolatedModules) compile by erasing types rather than analysing them. This tool follows the same model. It tokenizes your source with a parser that recognises strings, template literals, regular expressions, and comments as opaque units, then walks the tokens with a brace-context stack.

That context stack is what makes the conversion correct: inside an object literal a : is a real key-value separator and must be kept, while elsewhere a : introduces a type annotation and is removed along with the type expression that follows it. The transpiler also deletes whole interface and type declarations, removes generic type parameters like <T>, drops as/satisfies casts and non-null ! assertions, strips access modifiers such as private and readonly, and rewrites each enum into an equivalent JavaScript object with auto-incrementing values.

Example and limits

enum Role { Admin, Editor }
function greet(u: { name: string }): string {
  return "Hi " + u.name;
}

becomes a plain const Role = { Admin: 0, Editor: 1 }; plus an untyped greet. The tool does not type-check and does not down-level modern syntax to older targets, so pair it with tsc --noEmit for type safety and Babel for legacy output. Everything runs locally and stays private.

Ad placeholder (rectangle)