Advertisement

JSON to JSDoc

Convert JSON into JSDoc @typedef blocks. Document object shapes for editors and TypeScript checking without rewriting your JavaScript.

JSON input

Paste JSON, optionally name the root type, then generate.

Your JSDoc typedef code will appear here.
Advertisement

Types without TypeScript

Many codebases stay on JavaScript but still want editor intelligence. JSDoc typedefs deliver it: the generator converts a sample payload into @typedef blocks that VS Code understands natively.

Document API shapes inline

Paste the generated block above the function that fetches the data. Future readers see the exact response shape in a hover tooltip instead of guessing from code.

JSON to JSDoc FAQs

What does a @typedef give me?
It teaches your editor the shape of an object: hovering shows field types and autocomplete suggests properties, all without converting the file to TypeScript.
How do I connect it to my code?
Place the block above your code and reference it with @type {Root}, for example /** @type {Root} */ const data = await res.json().
How are nested objects documented?
Each nested object gets its own @typedef, referenced by name from the parent's @property lines, keeping large shapes readable.
How are optional fields marked?
Fields that were null or missing become @property {[type]} with square brackets, which is JSDoc's syntax for optional properties.
Does this work with checkJs?
Yes. With checkJs enabled, tsc type checks your JavaScript against these typedefs and reports mismatches like a TypeScript project would.
Advertisement