Turn a JSON payload or a JSON Schema into TypeScript interfaces, with nullability, optional fields and the places a single sample cannot tell you about marked.
Waiting for input
A JSON Schema states what is allowed.
Waiting for input
Paste a schema or a payload.
JSON to TypeScript Types runs entirely on your device — nothing is uploaded or stored.
You’re on the Free plan. Compare plans
One JSON sample is not a type, and the gap between them is where generated types go wrong. This generates the interfaces and marks every place the sample could not tell it the answer.
A field that is `null` in your sample could be `string | null` or could always be null. A field absent from the sample might be optional or might just not have been set. An empty array says nothing at all about its element type. Each of these is flagged rather than silently resolved to whatever the sample happened to show.
Arrays of objects are merged across their elements, so a field present in some and missing in others becomes optional rather than required-or-forgotten. That single behaviour removes most of the runtime surprises generated types produce.
Feeding it a JSON Schema instead gives better types, because a schema states what a sample can only suggest — `required`, `nullable`, enums, unions and formats are all declared. Where both are available the schema is the one to use.
Names are made safe for TypeScript without losing the original: a key that is not a valid identifier is quoted rather than mangled, so the type still matches the data.
Because the sample could not say. An empty array gives no element type and a `null` value gives no underlying type. Guessing would produce a type that compiles and is wrong, so the gap is marked instead.
By comparing objects in the same array. A key present in some elements and missing from others becomes optional. From a single object it cannot know, which is why a schema produces better output than a sample.
A schema, whenever you have one. It declares what is required, what is nullable and what the allowed values are — all things a sample can only hint at.
Treat them as a first draft. They describe the sample faithfully; whether the sample describes the API is a separate question, and the marked fields are where to check.
They are quoted rather than renamed, so the type keeps matching the data. Renaming them would produce a type that looks tidier and no longer describes the payload.