Free TypeScript to JavaScript Converter

Convert TypeScript to JavaScript online. Removes types, interfaces and generics from TS or TSX, compiles enums, and can keep JSX or turn it into React calls.

  • No upload, 100% private
  • Instant, in your browser
  • 100% free, no signup
Loading tool…
Read the complete guideHow to Convert TypeScript to JavaScript: Strip Types or Compile →

About the TypeScript to JavaScript tool

Sometimes you need plain JavaScript from TypeScript code: to paste an example into a project without a build step, run a snippet in the browser console, or share code with someone who doesn't use TypeScript. Deleting type annotations by hand is fiddly and easy to get wrong with generics and enums. This converter strips the types for you.

It uses Sucrase, a fast compiler that removes interfaces, type aliases, annotations, generics, as and satisfies expressions, and type-only imports. Enums are compiled to plain objects and constructor parameter properties such as constructor(private name: string) become normal assignments. For .tsx files you can keep the JSX as is, compile it to react/jsx-runtime calls, or use classic React.createElement. You can also convert ES module imports to CommonJS require, and tidy the result with Prettier.

This is a transpiler, not the TypeScript compiler: it does not type-check your code, and modern syntax such as optional chaining is kept rather than down-levelled. Everything runs in your browser.

How to use TypeScript to JavaScript

  1. Paste TypeScript into the input, open a .ts or .tsx file, or click “Load sample”.
  2. Choose the “File type”: .tsx for code with JSX, or .ts to allow <T>value style casts.
  3. For TSX, pick the “JSX output”: Keep JSX, react/jsx-runtime or React.createElement.
  4. Toggle “Convert imports to CommonJS” and “Tidy with Prettier”.
  5. Copy the JavaScript or download it as .js or .jsx.

Features

Removes all type syntax

Interfaces, types, generics, annotations, as, satisfies and type-only imports.

Compiles enums and parameter properties

TypeScript-only runtime features become equivalent JavaScript.

Three JSX modes

Preserve JSX, target the automatic runtime or classic createElement.

ESM or CommonJS

Keep import/export or convert them to require and exports.

Prettier formatting

Optionally reformats the output so it reads like hand-written JavaScript.

When to use it

  • Share a TypeScript example with a team that uses plain JavaScript.
  • Run a TS snippet in the browser console or Node REPL.
  • Convert a .tsx component into .jsx for a JavaScript-only React project.
  • Check what an enum or parameter property compiles to.
  • Migrate small scripts away from a TypeScript build step.

Frequently asked questions

Does it check my types?

No. It only removes type syntax. Use tsc --noEmit or your editor to find type errors.

Which JavaScript version is the output?

The output keeps your modern syntax (ES2020 and later features such as ?. and ??). It does not down-level code for old browsers.

What is the difference between .ts and .tsx mode?

In .tsx mode angle brackets are JSX, so casts must be written with as. In .ts mode JSX is not allowed but <Type>value casts work.

Are const enums and namespaces supported?

Regular enums are converted. Const enums are compiled like regular enums rather than inlined, and namespaces containing values are not supported by Sucrase.

Is my code uploaded?

No. The conversion runs entirely in your browser.

Related tools