devkult_
tools29converters34
home/tools/data & json/JSON to TypeScript & Zod

JSON to TypeScript & Zod

Generate TypeScript interfaces, type aliases or a Zod schema from sample JSON. Merges array items and marks missing keys optional.

Loading tool…

Frequently Asked Questions

How are arrays of objects turned into a type?

Every element is merged into one shape. A key missing from some elements becomes optional (key?:), and a key whose type differs between elements becomes a union such as string | number. Paste several representative records for the most accurate result.

What happens to null values?

A field that is null in every sample is typed as null. If another sample has a value, the field becomes a union like string | null — in Zod, z.string().nullable(). Include a record where the field is filled in to get the useful type.

Should I use interfaces or type aliases?

For object shapes they are interchangeable in almost all code. Interfaces can be extended and merged by declaration; type aliases can also express unions and mapped types. Follow whatever your codebase already uses.

Why generate a Zod schema instead of plain types?

TypeScript types disappear at runtime, so they can't check that an API really returned what you expect. A Zod schema validates the data when it arrives and gives you the same static type through z.infer.

Is my JSON uploaded anywhere?

No. Type inference runs in your browser; the JSON never leaves your machine.