Embed this tool on your site
About this tool
TypeScript Playground transpiles TypeScript to JavaScript in your browser with the official TypeScript 5.3.3 compiler, which loads from the jsDelivr CDN the first time you click Transpile (about 10 MB, then cached by the browser). Your code is not sent to UtilityKit. Write TypeScript in the left editor, pick a target, choose whether to remove comments (ticked by default) and click Transpile to see the JavaScript in the right panel. Transpilation uses ts.transpileModule, which erases types one file at a time without type-checking, so the diagnostics box only reports syntax errors. Ticking Strict mode sets the compiler strict flag; because nothing is type-checked, its only visible effect is a "use strict" line at the top of the output. ES2020 (the default) and ESNext targets work as labelled, but the ES5 and ES2015 choices currently emit ES2015 and ES2019 code, so const, arrow functions and classes are not converted to ES5.
Why use it
Uses the official TypeScript 5.3 compiler, not a custom parser
Shows exactly how TypeScript-only syntax such as types, interfaces and enums disappears or compiles in plain JavaScript
Syntax errors are listed below the editors with their character position
Runs entirely in the browser — no Node.js or npm needed
Clear and Copy JS buttons make it quick to try one snippet after another
How to use
- Paste TypeScript code into the left editor — types, interfaces, generics and enums are all accepted.
- Choose a target from the selector (ES5, ES2015, ES2020 or ESNext); ES2020 is the default.
- Leave Remove comments ticked to strip comments, and tick Strict mode if you want a "use strict" prologue.
- Click Transpile — the TypeScript compiler loads from the CDN on first use and then transpiles your code.
- Copy the JavaScript output from the right panel with the Copy JS button.
When it helps
- Learning TypeScript and want to see what the compiled JS looks like for each construct you try
- Checking whether TypeScript syntax is valid before adding it to a project
- Demonstrating TypeScript features in a presentation or code review
- Verifying how generics, decorators, or optional chaining downlevel to older JS
- Quickly testing a TypeScript snippet without setting up a tsconfig
Examples
01Generic identity function (default ES2020)
Inputfunction identity<T>(value: T): T {
return value;
}
const n = identity<number>(42);
Expected resultfunction identity(value) {
return value;
}
const n = identity(42);
02Optional chaining (ES5 or ES2015 option)
Inputconst u: { name?: { first?: string } } = {};
const first = u.name?.first ?? 'unknown';
Expected resultvar _a, _b;
const u = {};
const first = (_b = (_a = u.name) === null || _a === void 0 ? void 0 : _a.first) !== null && _b !== void 0 ? _b : 'unknown';
03Async function (target ES2020)
Inputasync function fetchUser(id: number): Promise<{ id: number }> {
return { id };
}
Expected resultasync function fetchUser(id) {
return { id };
}
Tips
- Optional chaining and ?? are rewritten into _a/_b helper variables for targets below ES2020 — compare the ES2015 and ES2020 options to see the difference.
- Enums compile to a var plus an IIFE that fills in both name and value keys, while interfaces and type aliases vanish entirely.
- Pin the target to ESNext when sharing modern code for Node 20+ environments to keep async/await native.
- Remove comments is ticked by default — untick it to keep JSDoc and inline comments in the output.
- Type errors never block output: transpileModule erases the types and still emits JavaScript, so run tsc locally for real type-checking.
Frequently Asked Questions
Does this perform full type-checking?⌄
No. It uses ts.transpileModule, which erases types without semantic analysis. Only syntax errors (for example "Expression expected.") are reported; a type error such as assigning a string to a number produces no diagnostic and the JavaScript is still emitted.
Is my code sent to a server?⌄
No. The TypeScript compiler runs entirely in your browser via the CDN-loaded typescript.js bundle. Your code never leaves your machine.
Which TypeScript version is used?⌄
TypeScript 5.3.3, loaded from jsDelivr CDN on first use and cached by the browser for subsequent sessions.
What does the target selector control?⌄
It sets the compiler target. ES2020 (the default) and ESNext work as labelled. In the current build the ES5 option actually emits ES2015 code and the ES2015 option emits ES2019 code, so const, arrow functions and classes stay as they are; optional chaining and ?? are still rewritten for both of those options.
Can I use JSX or decorators?⌄
JSX (TSX) is not enabled in the playground. Experimental decorators may work depending on the target selected, but are not explicitly configured.
What does Strict mode do here?⌄
It sets strict: true in the compiler options. Because transpileModule does not type-check, strict checks such as noImplicitAny never report anything; the visible change is a "use strict" directive added to the top of the output.
Glossary
- Transpile
- The process of converting source code from one language or version to another while preserving behaviour — here, TypeScript to JavaScript.
- AST (Abstract Syntax Tree)
- A tree representation of source code that the TypeScript compiler builds during parsing; transpilation walks and rewrites this tree.
- ts.transpileModule
- A TypeScript compiler API that strips types from a single file without performing full project-level semantic analysis — fast but limited diagnostics.
- Downlevelling
- Transforming modern JavaScript syntax into equivalent older syntax — async/await to generator state machines, optional chaining to ternary expressions.
- Strict mode (tsconfig)
- A bundle of flags including strictNullChecks, noImplicitAny, and strictFunctionTypes that catch common type bugs at compile time.
- ESNext
- A target alias meaning 'the latest ECMAScript proposals supported by this TypeScript version' — emits the most modern syntax with minimal downlevelling.
- Type erasure
- TypeScript types are removed at compile time and have no runtime representation — a TS file with types compiles to JS with the types stripped.
- Diagnostics
- Compiler-emitted errors, warnings, and suggestions about your source code, surfaced by TypeScript's checker even when transpilation succeeds.
A LITTLE HELP. A LOT DONE.
Good tools.
Great flow.
Your shortcut to the everyday. Create, convert, calculate,
and get back to what you love.
✳
✳
✓ Free to use✓ No sign-up✓ 500+ possibilities