Skip to content
100% local

TypeScript to JSDoc comments

Turn TypeScript function and interface types into JSDoc comments so the types survive plain JavaScript.

Input
Output

TypeScript to JSDoc comments

Paste a TypeScript function, arrow function, interface or type alias and this tool writes the matching JSDoc comment above it — `@param` for every parameter, `@returns` for the return type, and `@typedef` with `@property` lines for object-shaped interfaces and type aliases. It is built for moving code from `.ts` to plain `.js` without losing the type information an editor or a JSDoc-aware linter still needs.

"Remove TypeScript annotations" strips the type syntax from the signature itself — parameter types, return types, generic parameter lists — leaving valid JavaScript with the same information now living in the comment; turn it off to keep the TypeScript untouched and just add documentation on top. "Generate @typedef for interfaces" turns an `interface` or an object `type` into a typedef block; "Add @template for generics" documents type parameters like `<T>`; "Add @throws from throw statements" scans each function body for `throw new SomeError(...)` and lists the distinct error types found. Comment style switches between the conventional aligned-star block and a tighter one-line-open variant, and line width controls where a long line wraps.

The tool reads top-level function declarations, arrow functions assigned to a `const` or `let`, interfaces and object-shaped type aliases — the declarations JSDoc has a tag for. Type annotations on local variables inside a function body, and methods defined inside a class or an object literal, are left as written; rewriting every type in a file safely needs a full compiler, and this stays a small, fast script that runs the moment you stop typing.

Everything runs locally in your browser — your code is never uploaded, so pasting from a private project is safe. Copy the result, download it as a .txt file, or send the output straight back into the input to run another tool on it next.

FAQ

Does it work on interfaces as well as functions?
Yes. Interfaces and object-shaped type aliases become an @typedef block with one @property line per member; a union or primitive type alias becomes a single-line @typedef instead.
What happens to the original TypeScript types?
With "Remove TypeScript annotations" on, the type syntax is stripped from the code and lives only in the comment above it, leaving plain JavaScript. Turn the option off to keep the TypeScript as-is and add JSDoc on top of it.
Does it document methods inside a class?
No. The tool documents top-level functions, arrow functions assigned to a const or let, interfaces and type aliases — class and object-literal methods are left untouched.
Where do the @throws tags come from?
The tool scans each function body for throw statements. A throw new SomeError(...) is reported as @throws {SomeError}; a bare throw is reported as @throws {Error}.
Is my code uploaded anywhere?
No. The conversion runs entirely in your browser — your code never leaves your device.