Free TypeScript to JavaScript Converter

Paste TypeScript or TSX, or open a .ts / .tsx file, and get clean JavaScript instantly: types, interfaces and generics are removed, enums, namespaces and parameter properties are compiled the way tsc --target esnext does, and your formatting and comments are kept. Optionally output CommonJS. Everything runs in your browser - your code is never uploaded.

0 lines โ€ข 0 characters

Options

Keep comments

When off, comments are removed except /*! license */ comments.

Paste TypeScript code to see JavaScript output

What the converter does

  • Removes type annotations, interfaces, type aliases, generics, as / satisfies, non-null !, access modifiers, overloads and declare statements.
  • Compiles enums, namespaces (including declaration merging) and constructor parameter properties the way tsc --target esnext does; the few patterns it cannot reproduce exactly are flagged with a warning.
  • Removes imports that are only used as types, like tsc. JSX in .tsx files is kept as JSX.
  • Does not type-check and does not down-level modern syntax. Standard decorators are kept as written; parameter decorators are removed with a warning. Run tsc in your project when you need type errors reported.

Understanding TypeScript to JavaScript Conversion

Type Erasure

Types only exist for the compiler. Removing them leaves JavaScript that behaves exactly like your TypeScript, because type annotations never change what code does at runtime.

Real Parsing

The code is parsed, not pattern-matched, so object literals, URLs in strings, ternaries and comparisons such as a < b are never mistaken for types.

Module Formats

Keep import / export for browsers, bundlers and modern Node.js, or convert to CommonJS require / exports for older Node.js projects.

Summary

A TypeScript to JavaScript converter removes the syntax that only TypeScript understands and leaves plain JavaScript that runs wherever JavaScript runs. To convert TypeScript to JavaScript free and privately here, paste your code into TypeScript Input, or click Open File, and the result appears in JavaScript Output with no Convert button. Then click Copy JavaScript or Download JavaScript. The tool runs in your browser and nothing is uploaded; you can check the Network tab in DevTools. Types, interfaces and generics are removed; enums, namespaces and parameter properties are compiled the way tsc --target esnext does; your formatting and comments are kept.

The rule behind it: a type never changes what code does at runtime, so deleting types leaves a program that behaves the same. The converter does not check types, so a file with type errors still converts if its syntax is valid, and it does not rewrite modern syntax for old engines.

Table of Use: What You Paste and What You Get

Examples of TypeScript input and the JavaScript the converter produces
SituationPasteResult
A typed variableconst url: string = "https://example.com/api";const url = "https://example.com/api";
Interfaces and type aliasesinterface User { id: number } and type ID = string | number;Removed completely
A numeric enumenum Direction { Up, Down }An object built by a function: Direction.Up is 0 and Direction[0] is "Up"
A string enumenum Status { Active = "ACTIVE" }Status["Active"] = "ACTIVE"; with no reverse mapping
A parameter propertyconstructor(private name: string) {}A name; class field and this.name = name; in the constructor
A React hook in TSXuseState<string | null>(null)useState(null), JSX kept as written
Output for Node.js requireModule output: CommonJS, then export const add = (a: number, b: number) => a + b;"use strict";, const add = (a, b) => a + b; and exports.add = add;
A syntax errorconst x: = 5;A Could not convert panel: Line 1, column 10: Unexpected "=", the line and a caret

Features

  • A real parser, not text patterns. The code is tokenized and parsed, and only the type syntax is cut out of your original text, so object literals, URLs in strings and comparisons such as a < b are never mistaken for types. Indentation, quotes, semicolons and comments stay.
  • What is removed. Annotations, interfaces, type aliases, generics, as and satisfies, non-null !, access modifiers, implements, overloads and declare statements.
  • What is compiled. Enums, namespaces (including merging with a class, function or enum) and parameter properties. Output behaves like tsc's but is not character-for-character identical: your formatting is kept, and an exported namespace constant is written as const x = 1; NS.x = x;.
  • Import clean-up. import type, type-only specifiers and imports used only as types are dropped. Side-effect imports and JSX component imports stay.
  • Three options. Module output (ES modules or CommonJS), Input (detect automatically, TypeScript or TSX) and Keep comments. With Keep comments off, comments go except /*! license */.
  • Files. Load Sample, or Open File for .ts, .tsx, .mts or .cts; you can also drop a file on the input box. A .cts file switches to CommonJS and .mts to ES modules. Downloads are named after the file (app.ts becomes app.js, .tsx becomes .jsx, .mts becomes .mjs, .cts becomes .cjs) or script.js for pasted code.
  • Errors and warnings. A syntax error shows its line and column. A Check these points box flags the rare cases tsc handles differently, such as removed parameter decorators or exported let or var variables copied once in CommonJS output.

Limits: it does not type-check, does not create .d.ts declaration files, does not rewrite import paths and converts one file at a time. Standard decorators are kept as written; projects built on experimentalDecorators need their own build setup. For older browsers, pass the result through Babel, esbuild or tsc with a lower target. Shrink the finished code with the JavaScript minifier.

How to Use the TypeScript to JavaScript Converter

  1. Paste your code into TypeScript Input, drop a file on it, or click Open File. Load Sample fills in an example.
  2. Under Module output choose ES modules (keep import / export) or CommonJS (require / exports).
  3. Leave Input on Detect TypeScript or TSX automatically, or pick TypeScript (.ts) or TSX if a snippet is read the wrong way.
  4. Switch Keep comments off to strip comments.
  5. Read JavaScript Output. Fix any Could not convert error it reports and look at the Check these points box if one appears.
  6. Click Copy JavaScript or Download JavaScript.

Who Can Use It

Developers can hand a snippet to someone who does not use TypeScript, move a file into a JavaScript-only project, or check what an enum or a namespace compiles to. Students learning TypeScript can see exactly what is erased and what becomes code. Compare the two versions with the text diff tool, and tidy the result with the JavaScript beautifier.

Authors can write documentation in the markdown editor and add the output with the code syntax highlighter. Check a tsconfig.json or package.json with the JSON validator and the JSON formatter, convert CI files with the YAML to JSON converter, and try the regular expressions in your code in the regex tester.

FAQs

How do I convert TypeScript to JavaScript online?

Paste your code into TypeScript Input, or click Open File and choose a .ts, .tsx, .mts or .cts file. The JavaScript appears in JavaScript Output without any button press. Choose ES modules or CommonJS under Module output, then click Copy JavaScript or Download JavaScript. The page runs in your browser and nothing is uploaded.

Does the converter check my code for type errors?

No. Like esbuild, Babel and Node.js type stripping, it parses the code and removes the TypeScript syntax, but it does not check that the types are correct. A file with type errors still converts as long as the syntax is valid. Run tsc --noEmit in your project, or rely on your editor, to see type errors.

What happens to enums, namespaces and parameter properties?

They become runtime code, compiled the way tsc --target esnext does it. A numeric enum becomes an object with a reverse mapping (Direction[0] is "Up"), a string enum gets none, a namespace becomes an object filled by a function, and constructor(private name: string) becomes a name field plus this.name = name. Constant values such as 1 << 2 are calculated, and const enums are emitted as normal enums.

Can I convert TSX React components?

Yes. TSX is detected automatically, or choose TSX - TypeScript with JSX (.tsx) under Input. Types inside JSX expressions are removed and generic calls such as useState<string | null>(null) lose their type arguments, while the JSX markup is kept as written, so the result is JSX for your bundler. Imports used only as JSX tags are kept.

Which imports are removed?

import type statements, type-only specifiers such as { type User }, and imports whose names are only used in type positions are removed, as tsc does without verbatimModuleSyntax. Imports used in your code, side-effect imports such as import "./styles.css", and a React import when JSX is present are kept.

Should I choose ES modules or CommonJS?

Keep ES modules for browsers, bundlers such as Vite or webpack, and Node.js projects with "type": "module". Choose CommonJS for Node.js code that uses require: imports become require calls, exports become exports.name assignments, and default imports follow esModuleInterop. CommonJS exports are copied once, so a later reassignment of an exported let is not seen by other modules.

Can I run TypeScript without converting it?

Often. As of October 2026, the Node.js documentation says versions from 22.18 and 23.6 onward run .ts files by replacing types with whitespace, with no type checking. Syntax that needs generated code, such as enums, namespaces with runtime code and parameter properties, produces an error there, and this converter compiles it. Browsers cannot run TypeScript at all.

Is my code uploaded anywhere?

No. This tool runs in your browser and nothing is uploaded; you can check the Network tab in DevTools. Pasted code is converted by JavaScript on the page, and a file you open is read locally by your browser, so your source code stays on your device.