JSON to JSDoc @typedef Generator
Paste any JSON object or array and get ready-to-use JSDoc @typedef definitions, with each field mapped to a JSDoc type (string, number, boolean, type[]) and separate @typedef blocks for nested objects. Perfect for adding types to plain JavaScript without TypeScript. null and empty arrays become the * (any) type. Everything runs locally in your browser — your JSON is never uploaded.
How to use
- Paste or type your JSON into the input box.
- Optionally rename the root typedef (defaults to Root).
- Copy the generated @typedef blocks into your JavaScript source.
Frequently asked questions
- How are types mapped?
- Strings become string, all numbers become number, booleans become boolean, and arrays become type[] based on their first element. Nested objects each get their own @typedef and are referenced by name.
- What about null or empty arrays?
- Their type can't be inferred from the sample, so null maps to * (any) and an empty array maps to *[]. Tighten these by hand if you know the real type.
- Why JSDoc instead of TypeScript?
- JSDoc @typedef lets you document and type-check plain JavaScript (for example with VS Code or tsc --checkJs) without adding a build step or .ts files.
- Is my JSON sent anywhere?
- No. Conversion happens entirely in your browser; nothing is uploaded.
Related tools
JSON → TypeScript Interface
Generate TypeScript interfaces from any JSON sample — types are inferred recursively and named after each key.
Mock Data Generator
Generate realistic fake records for testing — names, emails, dates, IDs, lorem — exported as JSON, CSV, or SQL INSERTs.
JSON to Go Struct Converter
Turn a JSON object into a typed Go struct with json tags, instantly in your browser.
JSON to Python Dataclass Converter
Turn a JSON object into Python @dataclass definitions with type hints, in your browser.
JSON to Rust Struct Converter (serde)
Turn a JSON object into Rust structs with serde derives and type-mapped fields, in your browser.
JSON to Kotlin Data Class Converter
Turn a JSON object into Kotlin data classes with typed properties, in your browser.