Typescript Playground
Write and run TypeScript right in your browser. Type your code, see it transpiled and executed instantly — no install, no account, free.
TypeScript code
Press Run to transpile and execute your code.
Output
Nothing run yet.
Transpiled JavaScript
The transpiled code will appear here.
Worked Example
Take this TypeScript: "const x: number = 5;" becomes "const x = 5;" A function such as "function add(a: number, b: number): number { return a + b; }" becomes "function add(a, b) { return a + b; }" and add(2, 3) returns 5. An interface block such as "interface User { name: string; }" is removed completely, and a cast such as "const y = 10 as number;" becomes "const y = 10;" A simple enum such as "enum Color { Red = "red", Green = "green" }" becomes "const Color = { Red: "red", Green: "green" };"
Common Mistakes
Expecting real type checking. This playground only strips the type syntax. It never checks that a value matches its type, so passing a string where a number is expected runs without complaint.
Using features the transpiler does not know. Decorators, namespaces, generics on classes, object-type annotations, and typed class properties are not handled, and declaring several typed variables in one statement is not handled either — declare them separately. Keep the code to variables, functions, interfaces, type aliases, simple enums, and casts.
Writing an enum with computed members. Only plain string and number enum members convert to an object. An enum member that calls a function or uses an expression is left alone, and the code will fail to run.
Forgetting console.log. Only console.log output appears in the output pane. A value that is computed but never logged shows nothing, even though the code ran fine.
Related Tools
Format structured data with the YAML Formatter, turn JSON into a spreadsheet with the JSON to CSV Converter, or browse every tool in the Tools hub.
Frequently Asked Questions
Is this a real TypeScript compiler?
No. It is a small built-in transpiler that strips type annotations, removes interface and type alias blocks, converts simple enums to objects, and drops "as" casts. There is no real type checking, and it only handles the common syntax listed on this page.
What TypeScript syntax is supported?
Variable and function annotations, function return types, interface blocks, simple type aliases, "as" casts, access modifiers, arrow functions, and simple string or number enums. Decorators, namespaces, generics on classes, and typed class properties are not supported.
Does my code leave my browser?
No. The transpiling and the execution both happen in your browser. Nothing is sent to a server, and nothing is stored.
Why does my code show an error?
Either the JavaScript underneath has a real error, or the code uses TypeScript syntax this small transpiler cannot strip. Simplify the code, remove the unsupported feature, and try again.
Can I run code that uses the page or the network?
Only console.log output is captured. Code that touches the page, the network, or timers may behave oddly or not at all, because the playground runs it in a plain function with a fake console.