Online TypeScript Compiler
Compile TypeScript with the official 5.9 compiler and run the result in your browser. Syntax errors are reported; types are erased, not checked.
Start from an example
main.ts
Standard input (stdin)
Output
Nothing has run yet
Press Run to see what the program prints, or load one of these:
TypeScript, compiled by the real compiler
Your code goes through the official TypeScript 5.9 compiler in transpile-only mode. The JavaScript it produces runs in your browser's engine, inside a sandboxed Web Worker.
Know this before you start: types are erased, not checked. A syntax error stops the run, but const n: number = 'text' runs without complaint. For type errors, run tsc --noEmit on your machine.
- Compiler
- TypeScript 5.9.3
- Mode
- Transpile only
- Output
- ES2022, CommonJS
- Input
- prompt(), readline, fs.readFileSync(0)
- Run limit
- 10 seconds
- First load
- About 9 MB, then cached
What works and what does not
We ran every row of this table in the compiler before writing it down.
| Feature | Works? | Details |
|---|---|---|
| Interfaces, generics, unions, enums Removed or turned into plain objects, the same as tsc does. | Yes | Removed or turned into plain objects, the same as tsc does. |
| satisfies, optional chaining, ??= Anything the 5.9 parser understands. | Yes | Anything the 5.9 parser understands. |
| Decorators (TC39 standard) Method and class decorators run as written. | Yes | Method and class decorators run as written. |
| import and export Compiled to CommonJS, so import * as readline from 'readline' and import fs from 'fs' both work. | Yes | Compiled to CommonJS, so import * as readline from 'readline' and import fs from 'fs' both work. |
| Syntax errors Shown as main.ts(line,column): error TS…, and the run stops. | Yes | Shown as main.ts(line,column): error TS…, and the run stops. |
| Type checking Type errors are not reported. The code runs anyway. | No | Type errors are not reported. The code runs anyway. |
| Line numbers in runtime errors You get the message without a line, because the line would point at the compiled JavaScript. | No | You get the message without a line, because the line would point at the compiled JavaScript. |
| npm packages, DOM, network Same limits as the JavaScript compiler. | No | Same limits as the JavaScript compiler. |
Why run TypeScript here
The real compiler, not a type stripper
Enums, namespaces and parameter properties need generated code, and they get it, because this is TypeScript’s own compiler.
import syntax works
Unlike the JavaScript compiler, you can write import fs from 'fs'. It becomes a require() call before the code runs.
Same input helpers as JavaScript
prompt(), readline and fs.readFileSync(0) read the stdin box, so the same input code works on both pages.
One download
The compiler is about 9 MB (under 2 MB compressed). Your browser caches it, so the next visit skips the download.
Errors you will probably hit
Two of these are about what the compiler does not do.
main.ts(1,19): error TS1109: Expression expected.
What it meansA syntax error. The numbers are the line and the column.
FixGo to that spot. The problem is usually a missing value, bracket or comma just before it.
No error for const n: number = 'text'
What it meansTypes are erased, not checked.
FixRun tsc --noEmit locally when you need type errors.
Error: Cannot find module 'express'
What it meansnpm packages are not available. An import you never use is dropped by the compiler, so this only appears once the import is used.
FixRemove the dependency, or write the part you need by hand.
TypeError: Cannot read properties of null (reading 'x')
What it meansA value was null at run time, whatever its type said.
FixGuard it with optional chaining (o?.x) or an if check. Runtime errors have no line number here, so a console.log helps you find the spot.
How this Online TypeScript Compiler works
When you press Run, the page passes your code and stdin to a sandboxed frame that cannot see this site, your cookies or the network. Inside it, a Web Worker loads the TypeScript compiler, turns your code into JavaScript and runs the result.
The compiler downloads on the first run and your browser caches it. If the code has a syntax error, you see the compiler's message and the run stops there. Type errors are not checked.
How to use this Online TypeScript Compiler
Write your code
Start from the sample, pick an example above the editor, or paste your own.
Add stdin
One value per line. prompt() and readline() each take one line per call.
Run it
Press Run TypeScript or Ctrl+Enter. The first run downloads the compiler, then the output appears on the right.
Example Usage
A generic helper that groups numbers by the key a function returns.
Frequently Asked Questions
Does this check my types?
Which TypeScript version and settings are used?
Can I use import and export?
How do I read input?
Is my TypeScript code sent to a server?
Why is the first run slower than in the JavaScript compiler?
Related Tools
Online Code Formatter
Universal code beautifier for Python, Java, Swift, JavaScript, C#, HTML, and CSS. Clean up messy code instantly.
Online Syntax Highlighter
Highlight your code with syntax coloring for various languages. Generate HTML with inline styles or classes.
JS Formatter
Beautify JavaScript code.
Source Code Viewer
View and analyze source code with syntax highlighting. Supports HTML, CSS, JavaScript, and more.
JavaScript Compiler
Write and run JavaScript online with stdin input, exit codes and instant output. It runs in a sandbox in your browser, so your code is never uploaded.
Python Compiler
Run Python 3 online with the full standard library and stdin input. It uses Pyodide (WebAssembly) in a browser sandbox, so your code is never uploaded.
Comments
Comments are provided by Disqus, which sets cookies and processes data under its own privacy policy.
The Online TypeScript Compiler is maintained by CodeItBro. We aim to provide the best free developer tools on the web. If you have feedback or suggestions, please visit our contact page.

