TypeScript playground

Run TypeScript online

Write and run TypeScript online with Node.js. A free TypeScript compiler in your browser: see console.log output and errors, with nothing to sign up for.

Code main.ts

// Welcome to the coding.kitty TypeScript playground.
// Press Run (or Ctrl+Enter) to see what this prints.

interface Cat {
  name: string;
  age: number;
}

const cats: Cat[] = [
  { name: "Miko", age: 3 },
  { name: "Nola", age: 5 },
  { name: "Baymax", age: 1 },
];

function describe(cat: Cat): string {
  return `${cat.name} is ${cat.age} and says meow`;
}

cats.forEach((cat, index) => console.log(`${index + 1}. ${describe(cat)}`));

// Type something in the Input box, then remove the // from these three lines:
// import { readFileSync } from "node:fs";
// const input: string = readFileSync(0, "utf8");
// console.log(`You typed: ${input.trim()}`);
Output

Press Run to see what your code prints.

About this TypeScript playground

This is a TypeScript compiler you can use straight away. Write TypeScript in the editor, press Run, and the output appears next to it: everything you console.log, any error with its stack trace, and how long it took.

Your code runs on Node.js in an isolated sandbox on our servers. Node removes the type annotations and runs what is left, so there is no build step and nothing to configure. That also means your types are not checked: a type error does not stop the run.

A few TypeScript features need code generated rather than types removed, and those are not supported: enums, namespaces that hold values, and parameter properties such as constructor(private name: string). Use a union of string literals, or an object with as const, instead of an enum.

What you can run

  • TypeScript on Node.js 22, running one file per run, saved as main.ts.
  • Standard library only. Every built-in of the language is there (Math, JSON, Date, Map, Set, Promise and the rest), plus Node's own modules such as fs, path, util and crypto, loaded with import or require(). There is no package installer, and programs have no network access.
  • Limits: 10 seconds and 256 MB of memory per run. Output past 64 KB is cut off, code can be up to 64 KB and input up to 16 KB.
  • Fair use: 5 runs a minute and 50 a day without an account, 10 a minute when you are signed in.

Reading input

Open the Input box under the editor and type what your program should read. Node hands it to your program as standard input, which you can read all at once with fs. With the box empty, you read an empty string.

import { readFileSync } from "node:fs";
const input: string = readFileSync(0, "utf8");

Frequently asked questions

Is this online TypeScript compiler free?

Yes. There is no sign-up and no limit on how much you can write. Signed-out visitors get a quick, usually invisible bot check when they press Run, and a fair-use cap of 5 runs a minute and 50 a day. Signing in raises it to 10 runs a minute.

Does the playground check my types?

No. Node.js runs TypeScript by removing the type annotations and running the JavaScript that is left, so a type error does not stop your program and is not reported. The editor highlights TypeScript syntax, but to check types, run tsc on your own machine.

Which TypeScript features are not supported?

The ones that need JavaScript generated, not just types removed: enums, namespaces that hold values, parameter properties (constructor(private name: string)) and import x = require(). Using one stops the run with ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX. Interfaces, type aliases, generics, unions and type-only imports all work.

Can I use npm packages?

No. The playground runs the language and Node's built-in modules only: there is no npm install, and programs have no network access, so fetch() calls to other sites fail.

Why did my program stop with a time-out?

Each run gets 10 seconds and 256 MB of memory. A program that goes past either is stopped. The usual cause is a loop that never ends, or a timer such as setInterval that keeps the program alive.

Is my code saved or shared?

Your code is kept in your own browser so it is still there next time, and nowhere else. When you press Run it is sent to our code runner, run once in a sandbox, and thrown away. We do not store it or show it to anyone.

Keep going

Also in the playground: Python, JavaScript, SQL, Bash, C, C++, Go, Rust, Java, C#, Ruby, PHP, Lua, R, Dart, Swift.