TSX to JSX Converter — Strip TypeScript from React

Strip type annotations, generics, interfaces, type aliases, and as-assertions from TSX components. Heuristic regex pipeline — fast, predictable, 100% in your browser.

What does TSX to JSX do?

A TSX to JSX converter strips the TypeScript-specific syntax — type annotations, generics, interfaces, type aliases, as assertions, and access modifiers — from a React component, leaving plain JSX behind. The runtime behaviour is unchanged because TypeScript types are erased at compile time; what you remove is the static layer the type-checker uses, not anything the browser executes.

This tool is a regex-based heuristic stripper, not a TypeScript compiler. It covers the common 80% case — components with typed props, state, event handlers, refs, and the occasional generic helper — fast and predictably. Read the output before relying on it, especially for code with conditional types, type predicates, satisfies clauses, or namespace blocks. For production-grade transpilation use the official TypeScript compiler or Babel @babel/preset-typescript.

How to convert TSX to JSX — 4 steps

  1. Paste your TSX. Drop a React component file (.tsx) or any TSX snippet into the Input panel. Click Load Sample to try a typed Card component.
  2. Click Convert. The regex pipeline runs in your browser — interfaces are dropped, annotations stripped, generics and assertions removed.
  3. Review the output. Confirm props names survived, JSX tags are intact, and there are no leftover type fragments. The conversion is heuristic, so verify before shipping.
  4. Copy and use. Paste into a JS-only sandbox (CodePen, JSFiddle), a Stack Overflow answer, a JavaScript codebase, or a tutorial.

What gets stripped

1. Parameter and variable annotations

Every identifier: Type annotation between a colon and a comma, paren, equals, or newline is removed.

// Before
function greet(name: string, age: number = 30): string {
  const ok: boolean = age > 18;
  return `hi ${name}`;
}

// After
function greet(name, age = 30) {
  const ok = age > 18;
  return `hi ${name}`;
}

2. Interfaces and type aliases

interface Foo { ... } and type Foo = ...; are removed entirely. The blank line they leave behind is collapsed.

// Before
interface User { id: string; name: string; }
type Status = 'idle' | 'loading' | 'done';

// After
// (both lines removed)

3. Generics and assertions

Generic parameters on declarations and call sites are stripped, along with as Type and as const assertions.

// Before
function get<T>(x: T): T { return x; }
const ids = [1, 2, 3] as const;
const v = (data as Response).status;

// After
function get(x) { return x; }
const ids = [1, 2, 3];
const v = (data).status;

Type-Erasure Aware

Strips the syntax that has no JavaScript counterpart — annotations, interfaces, generics, assertions — and leaves runtime code intact.

Predictable Heuristics

Pure regex pipeline, no AST. The same input always produces the same output. Limitations are documented and well-defined.

Browser-Only

The pipeline runs in JavaScript on your machine. Proprietary components and unreleased features never leave the device.

Common use cases

  • check_circlePosting a minimal-repro to a JavaScript-only sandbox like CodePen or JSFiddle
  • check_circleSharing a React example on Stack Overflow under a JS-only tag
  • check_circleDowngrading a component for a project that has not migrated to TypeScript
  • check_circleProducing a JS variant of a component for a beginner-friendly tutorial
  • check_circleStripping types for a quick paste into a browser console or REPL
  • check_circleForking a TypeScript example into a JavaScript-only build pipeline
  • check_circleGenerating a smaller code sample for a screenshot or blog post
  • check_circleDiffing the runtime semantics of TSX vs JSX side-by-side

Heuristic stripper vs proper compiler

A regex pipeline is fast, predictable, and easy to audit — but it does not understand the grammar of TypeScript. Some constructs the heuristic does not handle: conditional types in expression position (T extends U ? A : B outside a type alias is rare but exists in advanced libraries), type predicates (function isUser(x): x is User leaves a syntactic fragment if the predicate body wraps the colon awkwardly), satisfies expressions, namespace declarations, and deeply nested generic constraints with brackets in unusual positions. For these, run the official tsc --jsx preserve --target esnext --noEmit false --emitDeclarationOnly false or use Babel with @babel/preset-typescript. Both are AST-based and handle every grammatical edge case.

Need to go the other direction?

Convert plain JSX up to TSX, beautify TypeScript, or format a JSX component — all browser-side.

Frequently Asked Questions

What does the TSX to JSX converter strip?

It removes the TypeScript-only syntax that has no JavaScript runtime equivalent: parameter and variable type annotations (foo: string), return type annotations on functions (): Promise<X>, generic parameters on declarations and call sites (<T extends ...>), interface blocks, type aliases, enum declarations, as Type / as const assertions, the non-null ! operator, optional ? markers on parameters and properties, public/private/protected/readonly/override modifiers on class members, declare statements, and import type / export type lines. JSX syntax, runtime imports, and JavaScript expressions are preserved verbatim.

Is this a complete TypeScript-to-JavaScript compiler?

No. This is a regex-based stripper, not a parser. For a fully correct conversion that handles every edge case — nested generics, type predicates, satisfies, assertion functions, decorators, namespace blocks — use the official TypeScript compiler with isolatedModules: true and emitDeclarationOnly: false, or use Babel with @babel/preset-typescript and the onlyRemoveTypeImports flag. This tool is for quick one-off downgrades of a snippet, not for production transpilation pipelines.

Why would I need to convert TSX back to JSX?

Several real reasons: posting a minimal-repro to a JS-only sandbox like CodePen or JSFiddle that does not support TypeScript; sharing code in a tutorial aimed at JavaScript-only readers; downgrading a contribution to a project that still uses plain JavaScript; pasting an example into Stack Overflow under the [reactjs] tag where TypeScript would be off-topic; and forking a TypeScript example to wire into a JavaScript-only build pipeline you do not control.

Will the output run as-is?

Usually yes for straightforward components — props, state, event handlers, conditional rendering, and lists all survive the conversion. Watch for: complex generic constraints that the regex over-strips, type predicates (foo is Bar) that leave syntactic fragments, satisfies clauses, and conditional types in expression position. Run the output through a JSX-only linter or a quick Node REPL of the file before relying on it.

Does it preserve comments and import order?

Yes. JSDoc /** */ blocks, single-line // comments, and block /* */ comments are passed through untouched. Runtime imports (import React from "react") stay in place. Only `import type { X } from "..."` lines are removed because they have no JavaScript counterpart — if you used a default-import bundle (`import { type X, foo } from "..."`), the inline `type` keyword is dropped but the runtime import is preserved.

How are generics in JSX handled?

Generic parameters on function CALLS — foo<T>(arg) — are stripped to foo(arg) when followed by an opening parenthesis. JSX tags — <Component prop="..."/> — are preserved because the regex requires a `(` immediately after the closing `>`, which JSX does not have. Edge cases like <T,>(x) => ... in arrow function generics are handled by a dedicated rule that matches the arrow-fn ambiguous-paren pattern.

What about React.FC and component type annotations?

A signature like `const Card: React.FC<CardProps> = (props) => ...` becomes `const Card = (props) => ...` — the `: React.FC<CardProps>` annotation matches the variable-type rule and is dropped. The accompanying `interface CardProps { ... }` declaration is removed by the interface rule. The result is plain JSX with the same runtime behaviour minus the type-checking layer.

Is the code I paste sent to your servers?

No. Conversion runs entirely in JavaScript on your machine. Components containing API keys, proprietary types, internal naming, or unreleased features never leave your browser. Open DevTools → Network and click Convert to confirm — no requests are made.

TSX to JSX Converter Online — Strip TypeScript from React