JSON to TypeScript
Paste a JSON payload and get TypeScript interfaces you can drop straight into your codebase. Nested objects become named interfaces, arrays become typed lists, and a value that appears as both a number and a string becomes a proper union — the strictest type that fits everything the generator actually saw.
TypeScript’s ? and | null mean different things, and this tool keeps them apart: a field missing from some samples becomes optional (name?: string), while a field that is present but null becomes nullable (name: string | null). Paste two or three real API responses as separate samples and they merge into one interface that is honest about which is which.
Repeated string values like "active" / "archived" can be promoted to enums, and ISO timestamps can map to Date — both are toggles, because sometimes you really do want plain string.
How JSON type inference works
The generator reads your JSON and builds the strictest type that fits every value it saw: objects become interfaces, structs or classes; arrays become typed lists; a value that appears as both a number and a string becomes a union. Repeated string values (like "active" / "inactive") can be promoted to an enum, and ISO 8601 timestamps or UUIDs can map to your language's date and UUID types — both are toggles above.
Why add multiple samples?
One API response rarely shows every field — optional fields are missing, nullable fields happen to be set. Add two or three real responses with Add sample and they merge into a single type: a field present in every sample stays required, and a field that only some samples carry becomes optional. More samples always produce a more honest type.
Nullable is not optional
A field that appears as null in a sample is nullable — it is always present, but its value may be null (string | null). A field that is missing from some samples is optional — it may not exist at all (field?: string). Serializers treat the two very differently, which is why the generator keeps them distinct instead of collapsing both to "maybe".
JSON Schema in, types out
Already have a JSON Schema? Switch the input to JSON Schema and the types are derived from the schema's declared properties, required list and formats instead of being inferred from samples — or pick the JSON Schema output target to go the other way and generate a schema from samples.
FAQ
Does my JSON leave the browser?
No. The quicktype engine runs as JavaScript on your device — nothing is uploaded, and the generated types never touch a server. Paste production payloads with tokens in them without worrying.
How are optional fields detected?
By comparing samples. A field present in every sample stays required; a field missing from any sample becomes field?:. With a single sample every field looks required, so add a second real response for honest optionality.
What is the difference between optional and nullable?
field?: string means the key may be absent from the object; field: string | null means the key is always there but may hold null. Serializers treat the two very differently, so the generator never collapses one into the other.
Can I start from a JSON Schema instead of samples?
Yes — switch the input mode to JSON Schema and the interfaces are derived from the schema’s declared properties and required list instead of being inferred from examples.