TypeScript playground
Online TypeScript compiler
Write TypeScript, press Run and see the output. It runs in your browser with no install and no sign-up.
Ctrl/Cmd + Enter to run
Loading editor...
Output
Run your code to see its output here.How this TypeScript compiler works
- Type annotations are removed with Sucrase and the result runs as JavaScript in a Web Worker.
- The code is not type-checked when it runs. Switch to the Monaco editor to see type errors as you write.
- console output appears in the Output panel. Use input() to read from the Input box.
- There is no page or DOM, and import statements are not available. A program is stopped after 10 seconds.
Your code is saved on this device as you type. Press Share to get a link that contains your code, and anyone who opens it sees the same program.
Also try: Python compiler, JavaScript compiler
Questions about the TypeScript compiler
Does this check my types?
When the code runs, types are only removed, not checked. The Monaco editor option shows TypeScript errors in the editor while you type.
How is TypeScript turned into JavaScript?
With Sucrase, which strips type annotations, interfaces and similar syntax. Features that need real code generation, such as enums, are handled too, but decorators and some newer syntax may not be.
Which editor should I use?
The default editor is small and fast. Monaco, the editor from VS Code, adds type checking and autocomplete but downloads several megabytes. Your choice is remembered.
Can I use import or the DOM?
No. Programs run as a single script in a Web Worker, which has no page. Top-level await works.
Is my code sent to a server?
No. Your code runs in your browser. Snippets are saved on your device.