TSX to JavaScript Converter
Convert TSX components into plain JavaScript in one step. TypeScript types are removed and JSX tags become function calls, with classic createElement or automatic output to match your project.
How to Convert TSX to JavaScript
Quick answer: paste your TSX or open a file; the JavaScript appears below. Copy it or download the .js file.
-
1
Add your TSX
Paste it or open a file.
-
2
Choose options
Adjust the output on the right.
-
3
Check the JavaScript
Errors show the line number.
-
4
Copy or download
Save it as .js.
What You Get
What Is TSX?
TSX combines TypeScript and JSX: typed component code with HTML-like tags. It is common in modern web apps. Both the types and the tags must be converted before the code can run as plain JavaScript.
What Is JavaScript?
JavaScript is the programming language of the web. Every browser runs it, as do servers, build tools and many apps. Plain JavaScript output can be pasted into a script tag, a code playground, a simple project without build tools or any place that does not understand types or JSX.
Why Convert TSX to JavaScript?
TSX files need two conversions before they can run: types must go and tags must become JavaScript. Doing both here lets you share a component with someone who does not use TypeScript, paste it into a playground, or see exactly what the build will produce.
How the Conversion Works
Type annotations, prop types, interfaces, generics and type imports are removed, then each JSX tag becomes a function call with its props and children. Generic calls such as useState<number>(start) keep their logic without the type. Modern syntax is kept as written, and types are not checked.
Example
The sample counter loses its Props type and the <number> generic, and its markup becomes createElement calls for the div, the paragraph showing the label and count, and the button.
Tips
Generic arrow functions in TSX files must be written as <T,> to avoid confusion with tags; the same rule applies here. Choose require() for older environments.
Who Uses It?
Front-end developers, students and teams sharing component examples, technical writers preparing documentation snippets, and reviewers who want to see what a component compiles to. Because the code never leaves the device, it is also safe for private and client projects.
Step by Step
Paste your TSX into the input box, drop a file onto it, or press Open File. The JavaScript appears in the output box straight away and updates as you type, so you can fix errors and see the effect immediately. Adjust the options on the right. When it looks right, press Copy to put the result on your clipboard, or Download to save it as a .js file. Press Sample to see a worked example first.
Using Your JavaScript
Save the result as a .js file or paste it into a script, a code playground or the browser console. If the code still contains import statements, load it as a module or choose the require() option. Keep the original source as your master copy, because the types and tags make it easier to work on.
About the Output
Import and export statements are kept by default, which suits modern browsers and bundlers. Choose require() to get CommonJS output for older environments and some server setups. Comments and blank lines in your code are kept where possible, so the result stays readable. Line numbers in the output may differ slightly from the source because removed type declarations leave fewer lines.
Private, Free and Instant
The converter is free, with no sign-up and no limit beyond the 5 MB text size. Everything runs in your browser, so private source code, client projects and unreleased work are never uploaded or stored. It works on Windows, Mac, Linux and Chromebooks, and on tablets and phones.
TSX to JavaScript: Types Removed, Components Kept
TSX is TypeScript with JSX, popular for typed React components. To run it in a plain JavaScript environment, the types are stripped out and the JSX is compiled to function calls.
What disappears
Type annotations, interfaces, generics, enums used only as types, and access modifiers are all removed. They exist only to help you while you write and check code. The behaviour of your component does not change.
What remains
Your logic, hooks, props and JSX output. Because types are not checked here, errors that a type checker would catch are not reported; run the TypeScript compiler for that.
For plain TypeScript, see TypeScript to JavaScript.
Frequently Asked Questions
Questions about TSX to JavaScript