JSX to TSX Converter — Free Online React Migration Tool

Convert React JSX to TSX. Auto-generates an interface Props skeleton from inferred props references. 100% client-side — never uploaded.

What is the JSX to TSX Converter?

A JSX to TSX converter turns a plain React component (.jsx) into a TypeScript React component (.tsx) by inserting a generated interface Props block and annotating the component signature. It does not invent the types — every prop is typed any with a TODO marker — but it removes the tedious first 80% of a JS-to-TS migration.

The OpenFormatter converter is a regex-based, browser-side tool. It scans the source for props.X references, collects the unique Xs into a Set, and emits an interface Props block with each name typed any. The component signature is rewritten — function Foo(props) becomes function Foo(props: Props). Imports are preserved verbatim. The result is a starter .tsx file that compiles immediately, ready for you to replace each any with a concrete type.

How to convert JSX to TSX online — 4 steps

  1. Paste your JSX. Drop a React component into the Input panel.
  2. Click Convert. The tool extracts props.X references and builds an interface Props skeleton.
  3. Review the skeleton. Each prop is typed any with a TODO comment — replace each with the concrete type.
  4. Save as .tsx. Copy the result, save with a .tsx extension, and run tsc to surface any remaining type holes.

Sample input & output

Before (.jsx)

import React from 'react';

function Card(props) {
  return (
    <div onClick={props.onClick}>
      <h2>{props.title}</h2>
      <p>{props.body}</p>
    </div>
  );
}

After (.tsx)

import React from 'react';

interface Props {
  /* TODO: replace any with concrete types */
  body: any;
  onClick: any;
  title: any;
}

function Card(props: Props) {
  return (
    <div onClick={props.onClick}>
      <h2>{props.title}</h2>
      <p>{props.body}</p>
    </div>
  );
}

Auto-Inferred Props

Every props.X reference becomes a key in the generated interface — sorted alphabetically with a TODO comment.

Signature Rewrite

function Foo(props) becomes function Foo(props: Props). Arrow components and destructured props are also covered.

Imports Preserved

The interface is inserted directly after the last import line — your import block stays untouched, no reordering.

Common use cases

  • check_circleReact component cleanup — start a typed component without writing the interface boilerplate
  • check_circleCode review prep — present a typed version of a JS component for the reviewer
  • check_circleMigrating JSX to TSX — bulk-convert a folder of .jsx files as the first step of a TypeScript adoption
  • check_circleCodebase consistency — give a junior dev a typed scaffold to fill in instead of a blank file
  • check_circleOnboarding tutorials — show the typed shape of a component example in docs
  • check_circleRefactoring legacy React — extract a Props contract before reshaping internals
  • check_circleGenerating typed snippets for blog posts and tutorials
  • check_circleBridging plain JSX libraries into a TS codebase — produce a thin typed wrapper

JSX vs HTML, JSX vs TSX

JSX vs HTML

  • JSX uses className, HTML uses class
  • JSX attributes are camelCase
  • Self-closing tags need />
  • Braces { } embed JS expressions
  • JSX is JavaScript, not markup

JSX vs TSX

  • TSX adds type annotations to JSX
  • Generics need angle-bracket disambiguation
  • satisfies, as are TSX-only
  • Use .tsx for typed React
  • This converter bridges the two

More React + TS tools

After conversion, format and minify the result without leaving the browser.

Frequently Asked Questions

What is the difference between .jsx and .tsx?

A .jsx file is plain JavaScript with JSX syntax. A .tsx file is TypeScript with JSX syntax — the same component author surface plus type annotations, interfaces, generics, satisfies, as assertions, and decorators. Renaming the file extension from .jsx to .tsx is the trivial part of migration; the real work is filling in types so the TypeScript compiler can verify props, state, hooks, and event handlers.

How does the converter infer props?

It runs a regex over the source for the pattern props.X — every X that looks like an identifier is collected into a Set. The set becomes an interface Props block with each property typed as `any` and a TODO comment instructing you to replace each `any` with a concrete type. Inference is intentionally shallow: this is a starter skeleton, not a full type-flow analysis.

Why does every prop default to `any`?

Because regex extraction tells us which props are read but not what type they hold. We could guess (a prop named children → ReactNode, a prop named onClick → MouseEventHandler) but those guesses fail in 30% of real codebases. `any` is honest — it surfaces the migration as a TODO in your editor with a clear tag, and a TypeScript-aware IDE will offer quick-fixes once you replace it with a concrete type.

Does it handle destructured props?

Yes — the signature rewrite covers function Foo({ a, b }) -> function Foo({ a, b }: Props). However, props that are read only via destructuring (never as props.X) will not be detected by the regex pass and will not appear in the generated interface. After conversion, scan for unused or missing keys and refine the interface manually.

Does it preserve imports?

Yes. The converter detects the import block at the top of the file (lines starting with import or const X = require(…)) and inserts the generated interface immediately after the last import. Default exports, named exports, and side-effect imports all stay in place, untouched.

Will it convert class components?

Class components are detected via the class keyword, but the converter does not auto-annotate them. The pattern class Foo extends Component<Props, State> requires both a Props and a State interface — auto-generating both reliably is out of scope for this regex-based pass. Convert class components manually after the file extension and Props skeleton are in place.

Will it migrate to React.FC<Props>?

No — current React + TS guidance discourages React.FC because it implicitly adds children and complicates default props. The converter emits the modern function Foo(props: Props) form. If your codebase uses React.FC, run a search-and-replace after conversion.

Is my code uploaded to your servers?

No. Conversion runs entirely in JavaScript inside your browser. JSX containing API keys, proprietary algorithms, or unreleased features never leaves the device. Open DevTools → Network and click Convert to verify no requests are made.

JSX to TSX Converter — Free Online React TypeScript Migration