TypeScript to JavaScript Converter
Convert TypeScript to JavaScript with the official compiler: types removed, enums converted, ES2015 to ESNext output.
Runs in your browser. Nothing is uploaded.
How to use the TypeScript to JavaScript Converter
- Paste TypeScript into the left box, open a .ts or .tsx file, or press Load example.
- Choose the JavaScript version under Target and the module format.
- For .tsx files, choose how JSX should be output.
- Copy or download the JavaScript.
Plain JavaScript from TypeScript
Sometimes you need the JavaScript behind some TypeScript: to use a snippet in a project without a build step, to paste an example into a browser console, to share code with someone who doesn’t use TypeScript, or simply to see what the compiler produces for a feature such as enums or decorators. This page runs the TypeScript compiler in your browser and converts the file directly.
What the conversion does
- Removes types: annotations, interfaces, type aliases, generics,
ascasts,satisfies, non-null assertions andimport typestatements disappear. - Converts TypeScript-only features: enums and namespaces become plain objects, and constructor parameter properties become assignments.
- Lowers newer syntax to the chosen Target: with ES2015, optional chaining, nullish coalescing, async functions and class fields are rewritten in older syntax.
- Converts modules: keep
importandexport, or switch to CommonJSrequireandmodule.exportsfor older Node.js code. - Handles JSX: for .tsx files, keep the JSX as it is, or compile it for React’s automatic runtime
or classic
React.createElementcalls.
One file at a time
Each file is converted on its own, without reading the files it imports. That is the same as
compiling with isolatedModules, which most modern build tools use. A few patterns that depend on
other files, such as re-exporting a type without export type, may need the type-only keywords added.
Errors
Type errors aren’t reported because types aren’t checked. Syntax errors, such as a missing bracket or a misplaced colon, are shown with their line and column and highlighted in the editor.
Readable output
The output keeps your code’s structure and comments, so it remains readable. To format it in your preferred style, pass it through the JavaScript formatter; to shrink it, use the JavaScript minifier.
Private
Your code is converted on your device. Nothing is uploaded.
Frequently asked questions
Which compiler does this use?
The official TypeScript compiler, running in your browser. It converts each file the same way tsc does when a project has isolatedModules turned on.
Does it check my types?
No. Checking types needs every file in your project, so this page only reports syntax errors. Types are simply removed from the output.
What happens to enums and namespaces?
They become ordinary JavaScript objects, exactly as the compiler outputs them. Constructor parameter properties such as private name: string become assignments in the constructor.
Which target should I choose?
ES2020 or later suits current browsers and Node.js. Choose ES2015 or ES2017 for older environments; features such as optional chaining are then rewritten into older syntax.
Is my code uploaded?
No. The compiler runs in your browser and nothing is sent anywhere.
Tutorials
How to convert a TypeScript file to plain JavaScript
Turn a TypeScript class with an enum, an interface and parameter properties into plain JavaScript you can run anywhere.