Skip to content
Devtoolry

Online TypeScript Compiler

Compile and run TypeScript online. Your code is type-checked with the official compiler in strict mode, then runs in a sandboxed worker in your browser.

Runs in your browser · Nothing uploadedFree · No sign-up

Something not working, or missing a feature? Send feedback

About the TypeScript Compiler

The TypeScript Compiler type-checks your code with the official TypeScript compiler in strict mode, reports type errors with their location, then strips the types and runs the result in a sandboxed worker.

Your code runs in an isolated Web Worker in your browser, so it never leaves your device.

How to use the TypeScript Compiler

  1. Write or paste TypeScript.
  2. Choose whether type errors should stop the run.
  3. Click Run: type errors are listed first, with line and column, followed by the program output.
  4. Click Visualize to step through the program line by line on your original TypeScript lines.

Example

Catch a type error before running

Input

function total(prices: number[]): number {
  return prices.reduce((sum, p) => sum + p, 0);
}
const count: number = "3";
console.log(total([1, 2, count]));

Result

main.ts(4,7): error TS2322: Type 'string' is not assignable to type 'number'.

Found 1 type error.
Not running because of type errors (turn off "Stop on type errors" to run anyway).

The error gives the line and column (4,7) and the compiler’s error code, the same format tsc uses.

Common mistakes

  • Running with type errors. With "Stop on type errors" off the program runs anyway, and the mistake may only show up as a wrong result. Fix the errors first.
  • Expecting npm packages. There is no node_modules folder, so imports of packages such as lodash or zod cannot be resolved. Paste the code you need into the editor.
  • Strict null checks. Strict mode is on, so a value that may be undefined (for example the result of array.find) must be checked before use. That is usually the error you want to see.

Works well with the TypeScript Compiler

Frequently asked questions

Does it run code with type errors?

Type errors are always listed. With "Stop on type errors" on, the program does not run; switch it off to run the type-stripped JavaScript anyway.

Which compiler options are used?

Strict mode with a modern target, matching a typical new TypeScript project.

Can I step through TypeScript code?

Yes. Click Visualize: the types are removed (keeping every line where it was), and the program is recorded step by step, so the highlighted line, variables and return values match your TypeScript source. Type checking is skipped while visualizing; use Run to see type errors.

Which TypeScript version is used?

A recent release of the official compiler, loaded in your browser. Type checking runs in a Web Worker so the page stays responsive.

Is my code uploaded?

No. Type checking and running both happen in your browser.

Is TypeScript compiled?

Yes. The TypeScript compiler checks your types and then removes them, producing plain JavaScript that runs like any other script. This tool does both steps in your browser: it reports type errors first, then runs the JavaScript.

Do I need Node.js or npm to run TypeScript?

Not here. The compiler and the runtime both run in your browser, so you can try TypeScript without installing Node.js, npm or ts-node. Packages from npm cannot be imported in the sandbox.

Guides and tutorials