b2KIT

TypeScript Playground

Write TypeScript with real-time transpilation to JavaScript, type checking, and error highlighting.

Tested tool guide Tested browser tools Checked August 16, 2026

What TypeScript Playground does, with a checked example

Write TypeScript in the left pane and the emitted JavaScript appears on the right as you type, with type errors and warnings listed alongside. All parsing, type checking, and emission happen in the browser tab, so there is no project setup and no tsc install. The surprise most users hit: a type error does not stop emission. The compiler strips type annotations and emits JavaScript anyway, so red squiggles and output can coexist - the diagnostics and the emitted code are separate results. Related surprise: interfaces and type aliases vanish entirely, while enums and namespaces become real runtime objects.

Worked example

A concrete input and expected output from the current implementation.

Input

interface Point {
  x: number;
  y: number;
}
function distance(a: Point, b: Point): number {
  const dx = a.x - b.x;
  const dy = a.y - b.y;
  return Math.sqrt(dx * dx + dy * dy);
}
const p1: Point = { x: 0, y: 0 };
const p2: Point = { x: 3, y: 4 };
console.log(distance(p1, p2));

Expected output

function distance(a, b) {
    const dx = a.x - b.x;
    const dy = a.y - b.y;
    return Math.sqrt(dx * dx + dy * dy);
}
const p1 = { x: 0, y: 0 };
const p2 = { x: 3, y: 4 };
console.log(distance(p1, p2));

The interface and every type annotation disappear because types exist only at compile time; only runtime constructs survive. With a target of ES2015 or later the emitted code keeps its shape (an ES5 target would turn const into var). Running the snippet would print 5, since sqrt(9 + 16) is sqrt(25).

How the result is produced

1

Types are erased, code is kept

The compiler separates type-only constructs - interfaces, type aliases, parameter and return annotations, as casts, generic parameters - from runtime constructs and emits only the latter. Emitted JavaScript follows the configured target and module options: const survives an ES2015 target but becomes var under ES5, and async/await or classes are likewise preserved or downleveled. No type information reaches the output.

2

Diagnostics are a separate pass

Type checking runs over the source independently of emission and reports errors and warnings per line. Finding an error does not suppress output: the compiler emits JavaScript even for code with type errors unless noEmitOnError is enabled. Strictness options such as strict and noImplicitAny change which diagnostics appear, so the same source can pass clean under one configuration and fail under another.

Good uses

  • See what a piece of TypeScript actually compiles to - for example, confirm that a generic function or interface contributes zero runtime code before adopting it as a pattern.
  • Validate a snippet in isolation before pasting it into a project: catch type errors and missing imports without setting up a build.
  • Preview how syntax downlevels for older targets, such as the ES5 shape of async/await or class fields, when you need to know what a legacy runtime would actually receive.

Limits and checks

  • Diagnostics do not block emission. Red squiggles and emitted output can coexist, so do not read an error-free pane as proof the code is sound, or an error as proof you will get no output.
  • Output depends on options. The same source emits differently under target ES5 versus ESNext or module CommonJS versus ESNext, and strictness flags change which errors appear. Check the configured options before trusting either pane.
  • Type syntax is not the only thing erased. Enums, namespaces, and constructor parameter properties become real runtime code, so output can be longer than the input's type-heavy appearance suggests.

Common questions

Will the errors match what my project's tsc reports?

Only if the tool's compiler options mirror your tsconfig. Target, module, and strictness flags all change which diagnostics appear, and the tool compiles a standalone snippet: types imported from your project are unavailable, so errors involving them will not show here even if your real build fails. Mirror the relevant options for a fair comparison.

Is my code sent to a server?

No. Parsing, type checking, and emission all run in the browser tab, and the code never leaves your machine - closing the tab discards it. There is no upload step, no account, and nothing is cached on a server. If you need to share code, you copy the text yourself.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools