Paste TypeScript or TSX and get readable JavaScript in milliseconds: type annotations, interfaces and type imports are removed while your code, comments and formatting stay as they were. Keep JSX for a .jsx file or compile it for React.
Last updated:
Converts automatically as you type. Your code never leaves your browser.
Advertisement
Advertisement
How to use the TypeScript to JavaScript
Paste your TypeScript or TSX code, upload a .ts/.tsx file, or click Sample.
Choose the JSX output: keep JSX for a .jsx file, or compile it to React.createElement or the automatic runtime.
Pick the target and module format: modern syntax or ES2019, ES modules or CommonJS.
Read the JavaScript on the right; it updates as you type and shows syntax errors with their line.
Copy or download the result as a .js or .jsx file.
What gets removed and what gets compiled
TypeScript
JavaScript output
let n: number = 1
let n = 1
interface User { … }, type Id = string
Removed completely
import type { X } from './x'
Removed; imports used only as types are dropped too
function f<T>(x: T): T
function f(x)
value as string, obj!, x satisfies T
value, obj, x
constructor(private db: Db) {}
constructor(db) { this.db = db; }
enum Dir { Up, Down }
A plain object with Dir.Up === 0 and reverse mapping Dir[0] === "Up"
public, private, readonly, abstract, declare
Modifiers removed
Example
// TypeScript
export function total(items: { price: number; qty?: number }[]): number {
return items.reduce((sum, i) => sum + i.price * (i.qty ?? 1), 0);
}
// JavaScript
export function total(items) {
return items.reduce((sum, i) => sum + i.price * (i.qty ?? 1), 0);
}
Strip types or compile?
Most TypeScript tooling today, including esbuild, Babel, SWC, Vite and Sucrase, converts TypeScript by stripping types file by file, without type-checking. That is what this tool does, which is why it is fast and keeps your code readable. The official tsc compiler also type-checks and can down-level code to very old targets such as ES5, which needs helper functions and changes the code much more. If you only want the JavaScript version of a file, for example to paste into a browser console, a CodePen or a project that does not use TypeScript, stripping types is the cleanest option.
For a file with JSX, choose Keep JSX to get a .jsx file you can drop into a React project.
Choose CommonJS for older Node.js scripts that use require() instead of import.
Generic arrow functions in TSX need a trailing comma or constraint, such as <T,>(x: T) => x, so they are not read as JSX tags.
Frequently asked questions
How do I convert TypeScript to JavaScript?
Paste the code into the left box. The converter parses it and removes everything that only exists for the type checker: annotations such as : string, interfaces, type aliases, generic parameters, as and satisfies casts, non-null assertions (!) and import type statements. The remaining code is valid JavaScript.
Does it check my types?
No. Like Babel, esbuild and Sucrase in a build pipeline, it only removes types and does not report type errors. Use tsc --noEmit or your editor to type-check. Syntax errors, such as a missing bracket, are reported with their line and column.
What is the difference between keeping JSX and compiling it?
Keep JSX converts .tsx to .jsx: the markup stays as <div>…</div> for a bundler to handle. Classic compiles each element to React.createElement(...) calls, which run directly in the browser with React loaded. Automatic uses the React 17+ runtime and adds an import from react/jsx-runtime.
Which ES target should I choose?
Modern keeps the syntax you wrote, which every current browser and Node.js 14+ understands. ES2019 rewrites optional chaining (a?.b), nullish coalescing (a ?? b) and class fields into older equivalents for legacy environments.
What happens to enums?
TypeScript enums have runtime values, so they are compiled to a plain JavaScript object with the same keys and values. Each file is converted on its own, like the isolatedModules setting, so const enums are emitted as regular enums.
Is my code uploaded anywhere?
No. The Sucrase compiler is downloaded once and then runs entirely in your browser, so your source code never leaves your device.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.