01What is TypeScript to JavaScript?
Sometimes you just need the JavaScript. Maybe you want to paste a snippet into the browser console, drop it into a CodePen, or hand it to a project that has no build step. This converter does that with the real TypeScript compiler, not a pile of regular expressions. Here is how it works. The compiler is large, so it is not part of the page bundle. The first time you convert, the page loads the official typescript package and calls its transpileModule function. That is the same single-file API that bundlers use when they compile with isolatedModules turned on. Your source is compiled inside your own browser tab, and the code you paste is never uploaded to us. Because it is the actual compiler, the output follows tsc exactly. Interfaces, type aliases, generics, overloads, satisfies, as casts and non-null assertions are erased. Enums and namespaces become the same runtime objects tsc writes. Constructor parameter properties turn into class fields plus assignments. If a line starts with a decorator, the tool switches on experimentalDecorators so legacy decorators compile instead of failing. You get three controls. Target picks the language level, from ES2022 down to ES2015. Modules chooses between keeping import and export or converting to CommonJS require calls. A TSX switch treats the input as a React file and leaves JSX untouched. A quick worked example: paste enum Dir { Up, Down, Left = 10, Right } and the output is an immediately invoked function that fills a Dir object. Up becomes 0, Down 1, Left 10 and Right 11, and each number maps back to its name, so Dir[0] gives "Up". Switch Modules to CommonJS and an export const turns into an exports.load assignment with a "use strict" header. Syntax mistakes are reported with line and column numbers, taken from the compiler's own diagnostics. The output still shows whatever could be produced, so a stray colon will not wipe the page. Now the honest limits. There is no type checking at all. Passing a string where a number belongs compiles happily. Each snippet is compiled alone, so anything that needs another file is out of reach. A const enum imported from a different module cannot be inlined, for instance. Imports that are only used as types, or never used as values, are dropped, which can remove an import you kept for its side effects. For real projects, run tsc or your bundler and treat this page as a quick look.
JavaScript and TypeScript developers, technical writers and anyone who needs plain JS from a typed snippet. The tool runs entirely in your browser, so your data never leaves your device.
02How to use TypeScript to JavaScript
- Paste code into TypeScript Input, or load one of the built-in examples
- Pick a Target and a Modules option, and tick TSX (keep JSX as is) for React components
- Wait a moment the first time while the compiler loads, then read the JavaScript Output
- If Syntax problems are listed, fix the lines and columns they point to
- Click Copy Output to grab the result, or Reset to start over
03Worked examples
- Input:
const port: number = 3000; - Result:
const port = 3000; - Input:
enum Dir { Up, Down, Left = 10, Right } - Result:
var Dir; (function (Dir) { Dir[Dir["Up"] = 0] = "Up"; Dir[Dir["Down"] = 1] = "Down"; Dir[Dir["Left"] = 10] = "Left"; Dir[Dir["Right"] = 11] = "Right"; })(Dir || (Dir = {})); - This is exactly what tsc emits: members without a value count on from the previous number, and numeric members get a reverse mapping, so Dir[0] is "Up".
- Input:
class Repo { constructor(private readonly db: Db) {} } - Result:
class Repo { db; constructor(db) { this.db = db; } } - A constructor parameter property becomes a class field plus the assignment, which pattern-based strippers usually lose.
- Input:
import { a, type B } from './m'; const el = document.getElementById('x')!; export type { B }; - Result:
const el = document.getElementById('x'); export {}; - The non-null ! and the type-only import and export disappear. The import of a is dropped too, because it is never used as a value in this file; the compiler elides imports it can't see a runtime use for.
- Input:
import { readFile } from 'fs'; export const load = (p: string) => readFile(p, 'utf8', () => {}); - Result:
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.load = void 0; const fs_1 = require("fs"); const load = (p) => (0, fs_1.readFile)(p, 'utf8', () => { }); exports.load = load; - Modules set to CommonJS. Imported calls are wrapped in (0, fs_1.readFile) so the function runs without the module object as this.
- Input:
const x = (y as number) satisfies number; let z: = 1; - Result:
const x = y; let z = 1; - The compiler also lists 'Type expected.' for line 2 under Syntax problems, but still emits what it can.
04Common use cases
- Pasting a typed snippet from library docs into the DevTools console, which rejects type annotations
- Sharing an example with a teammate whose codebase is plain JavaScript
- Moving a small helper into a script tag, a bookmarklet or a Google Apps Script file
- Seeing what an enum, namespace, decorator or parameter property compiles to before using it
- Checking how async code grows when compiled down to ES2015 for an old browser
- Comparing ES module output with CommonJS output before publishing a small package
05Tips
- Imports that are only used as types are removed, and so are imports that are never used as values in the snippet. Add a use, or keep the import yourself, if you rely on its side effects.
- No type checking happens here. Run tsc --noEmit in the project when you need errors about types.
- Older targets add helper code: ES2015 output rewrites async functions into generator-based helpers, so pick ES2022 unless you need old browsers.
- Node 22.6 and later can run many .ts files directly by stripping types, which may remove the need for conversion altogether, but it rejects enums and other syntax that needs code generation unless you enable transform mode.
06Related concepts
type erasure, transpileModule, isolatedModules, TypeScript enums, tsc.
Frequently Asked Questions
What is TypeScript to JavaScript?
TypeScript to JavaScript is a free, browser-based developer tool on AIDToolStack. Strip TypeScript types from code It requires no installation or sign-up and works entirely in your browser.
Is TypeScript to JavaScript free to use?
Yes. No sign-up, no fees and no usage cap.
Does TypeScript to JavaScript store my data?
No. It runs in your browser; nothing is uploaded.