Data Format Conversions

JavaScript to TypeScript Converter

Start a JavaScript to TypeScript migration: types from your JSDoc comments become real annotations, @typedef becomes an interface, class fields set in the constructor are declared, and require() / module.exports become import / export. The result is checked with the TypeScript parser.
TypeScript compiler APIRuns in your browser

Workspace

Options

@param, @returns, @type and @typedef become TypeScript types.

Adds field declarations for this.x = … assignments.

How to use this tool

  1. 1Paste JavaScript or open a .js / .jsx file.
  2. 2Choose which conversions to apply.
  3. 3Review the notes: untyped parameters are listed so you can add types.
  4. 4Download the .ts (or .tsx) file.

Frequently asked questions

It always parses as TypeScript, and every type comes from your JSDoc or from obvious literals. Parameters without JSDoc are left as implicit any (or annotated as any/unknown if you choose), so strict mode may still ask you to add types — the notes count them.

TypeScript requires class properties to be declared. Fields assigned in the constructor are declared with their type; fields first set in other methods are declared optional (?).

For most code, yes. Default imports of CommonJS modules rely on "esModuleInterop": true, the default in new TypeScript projects. Turn the option off to keep require().

Yes. Files with JSX are converted to .tsx.