Online TypeScript Compiler

main.ts
// Online TypeScript compiler
// Write your code here and press Run.

interface Point {
  x: number;
  y: number;
}

function distance(a: Point, b: Point): number {
  return Math.hypot(b.x - a.x, b.y - a.y);
}

const origin: Point = { x: 0, y: 0 };
const target: Point = { x: 3, y: 4 };

console.log("Hello, TypeScript!");
console.log("Distance:", distance(origin, target));
Output

Output will appear here. Press Run or Ctrl + Enter.

Ready

About this TypeScript compiler

This free online TypeScript compiler turns your TypeScript into JavaScript and runs it straight away, so you can try interfaces, generics and enums without setting up a project.

It is built for learning and quick tests. Press Run and the output of console.log appears on the right. Because everything happens in your browser, there is nothing to install and no account to make.

How to use it

  1. Write your TypeScript in the editor, including type annotations, interfaces and generics.
  2. Press Run (or Ctrl + Enter).
  3. The types are removed and the resulting JavaScript is executed. Output from console.log appears in the output panel.
  4. Fix any errors shown in red and run again.

Features

  • Interfaces, generics, enums, type aliases and other TypeScript syntax
  • Top-level await and modern JavaScript features
  • Stop button for runaway loops
  • Dark and light themes, automatic saving in your browser, download as .ts

Good to know

Frequently asked questions

Does this check my types?

No. It removes the type annotations and runs the JavaScript that remains. Syntax errors are reported, but type errors are not. For full type checking, use the TypeScript compiler (tsc) in your own project.

Can I use import statements?

Not in this single-file editor. Put your code in one file and it will run.

Does it support enums and generics?

Yes, both work, along with interfaces, type aliases, abstract classes and most other TypeScript syntax.

Is it free to use?

Yes, with no sign-up. Your code runs in your own browser.

Other online compilers