JSON to TypeScript & Zod
Data, Regex & TextFormat & inspect JSON trees, convert JSON/YAML/CSV/TOML, generate TypeScript/Zod, and beautify SQL/XML/HTML.
100% client-side — files and inputs never leave your browser.
About this tool and how it works
Generating TypeScript types and Zod schemas from JSON
Hand-writing interfaces for a large API response is slow and error-prone. Paste a sample payload and this tool infers a TypeScript interface for every nested object and a matching Zod schema you can use to validate data at runtime.
Why both?
TypeScript types disappear at compile time — they cannot stop a malformed response from reaching your code. A Zod schema checks the real data when it arrives: const user = UserSchema.parse(await res.json()) either returns typed data or throws with a precise error. With z.infer<typeof UserSchema> you can keep a single source of truth.
How inference works
- Strings, numbers, and booleans map to
string,number, andboolean. - Nested objects become their own named interfaces, so the output stays readable.
- Arrays use the type of their elements; mixed arrays become unions.
nullvalues are typed asnull— widen them (e.g.string | null) when you know the real type.
Get better results from your sample
Inference only sees the sample you provide. Use a response that includes optional fields and non-empty arrays; an empty array gives no information about its items. After generating, review fields that are optional in practice and mark them with ? (TypeScript) or .optional() (Zod). Dates arrive as strings in JSON — consider z.string().datetime() or z.coerce.date().
Frequently asked questions
Does the output support optional fields automatically?
Only what the sample shows. A field missing from your sample cannot be detected; mark optional properties manually after generating.
Which Zod version does the schema target?
The output uses the core API (z.object, z.string, z.number, z.array, z.union) that is stable across Zod 3 and Zod 4.
Is my API payload sent anywhere?
No. Type inference runs locally in your browser, which makes it safe for internal API responses.
Other tools
Beautify, minify, validate with line errors, sort keys, and inspect JSONPath.
Convert bidirectionally between JSON, YAML, CSV, and TOML in your browser.
Beautify or minify SQL queries (Postgres/MySQL), XML, and HTML markup.
Live regex matcher, capture groups, replace preview, and quick presets.
Compare text, JSON, or code side-by-side or in unified diff view.
Convert camelCase/snake_case/slugs, count bytes/words, and deduplicate lines.
Live GFM preview, HTML export, and Markdown table generator from CSV/TSV.
Create direct wa.me links with pre-filled messages and downloadable PNG QR codes.
Merge, split, compress, rotate pages, and convert between PDF and images 100% locally.