TypeScript Playground
Check TypeScript for errors, see the JavaScript it becomes and run it, all in your browser, with several files and a zip download.
Press Run to check your code. Problems appear here.
console.log messages and errors appear here.
Shortcuts: Ctrl+Enter run · / search (use ⌘ on Mac)
Free Online TypeScript Playground
Check TypeScript and run it. Write code on the left and press Run: the compiler lists what is wrong, shows the plain JavaScript your code becomes, and runs it with a console. You can use several files that import each other, and everything happens in your browser, so your code is never uploaded. Check TypeScript for errors, see the JavaScript it becomes and run it, with several files that import each other.
How to use the playground
- Write TypeScript in main.ts. The sample imports a small helper from utils.ts.
- Press Run (or Ctrl+Enter). The first time, the compiler loads for a moment.
- Read the Problems list. Each line gives the file, line and column; click it to jump to the spot.
- Look at JavaScript to see your code without the types, and at the Console for what it printed.
Files, target and strict
Press + to add files and import them with import { name } from './file'. Run starts the file you have open. Target picks the JavaScript version of the result and Strict turns on the careful checks. The ⋯ menu downloads all files in one zip. For plain JavaScript without types, use the JavaScript Playground, and to tidy code first try the JavaScript Beautifier.
Worked example
Type this in main.ts and press Run:
let age: number = "twelve"; console.log(age);
Result: the Problems list shows TS2322 Type 'string' is not assignable to type 'number'. at line 1, column 5, with a short explanation. The JavaScript is let age = "twelve"; and the console prints twelve.
Common mistakes
- Expecting a type mistake to stop the code: types are removed first, so it still runs.
- Importing a package such as lodash before adding it: press Add packages first.
- Pressing Run while utils.ts is open: Run starts the open file, so open main.ts.
- Leaving a parameter without a type while Strict is on, which gives TS7006.