typescript-to-js
A TypeScript-to-JavaScript converter removes type annotations and emits plain JS β useful for: showing TS code to a JS-only audience, embedding snippets where TS isn't supported, debugging compiled output, learning what TS adds vs JS, and quick removal of TS for prototyping in JS-only contexts. The ZTools TypeScript to JS Converter uses the official TypeScript compiler with configurable target (ES5 / ES2017 / ES2020 / ESNext), preserves comments, supports React TSX β JSX, and handles modern features (decorators, async/await, optional chaining).
Use casesβ
StackOverflow / blog where TS isn't welcomeβ
Question/answer audience expects JS. Quick conversion strips types without manual work.
Quick prototyping in JS sandboxβ
CodePen, JSFiddle don't support TS without setup. Strip types, paste, run.
Learning TypeScriptβ
See how TS code compiles to JS β understand what types add (none at runtime) and what TS does at compile time.
Debugging compile outputβ
Suspect a TS bug? See exactly what JS is being emitted; check for unexpected transformations.
How it worksβ
- Paste TypeScript β Standalone code, modules, classes, JSX/TSX all supported.
- Pick target ES version β ES5 (legacy compat), ES2017 (async/await native), ES2020 (optional chaining native), ESNext (latest).
- Pick module system β ES modules / CommonJS / UMD / None.
- Convert β TypeScript compiler removes types, optionally lowers syntax to target ES version.
- Copy / download β .js file ready to use.
Examplesβ
Input: function add(a: number, b: number): number \{ return a + b; \}
Output: function add(a, b) \{ return a + b; \} β types removed.
Input: TSX: const Btn = (props: \{ label: string \}) => <button>\{props.label\}</button>
Output: JSX: const Btn = (props) => <button>\{props.label\}</button> β types stripped, JSX preserved.
Input: Class with private fields, ES5 target
Output: IIFE-wrapped function with prototype methods β full lowering for old browsers.
Frequently asked questionsβ
Why does the output differ between targets?
TS lowers modern syntax to older equivalents. Target ES5: async/await becomes generator + Promise polyfill. Target ESNext: keep async/await as-is.
Are decorators preserved?
Yes β TS Stage 3 decorators emit cleanly to ES2022+. For earlier targets, lowered to function calls.
Will my JSX still work?
TSX β JSX strips types; JSX itself is preserved. Use a JSX-aware bundler (Vite, Webpack) to compile JSX β React.createElement calls.
What about type-only imports?
Removed entirely β they have no runtime effect. import type \{ User \} becomes nothing.
Will the JS run identically?
Yes β TS types are erased at compile, so the JS behaves the same. Only edge case: enum / namespace / decorator emit JS code that didn't exist in TS source.
How is this different from tsc?
Same compiler, browser-friendly UI. For a project, run tsc from CLI; for one-off conversion, this tool.
Tipsβ
- Pick target ESNext for modern dev; ES5 only for legacy browser support.
- Type-only imports (
import type) are tree-shaken automatically. - JSX preserved β use a JSX bundler downstream.
- For libraries, ship both:
.tssource + compiled.js+.d.tsdeclarations. - For runtime-checked types, TS doesn't help β use Zod / io-ts / etc. for runtime validation.
Try it nowβ
The full typescript-to-js runs in your browser at https://ztools.zaions.com/typescript-to-js β no signup, no upload, no data leaves your device.
Last updated: 2026-05-06 Β· Author: Ahsan Mahmood Β· Edit this page on GitHub