JSON to TypeScript, Zod, Go, Python and JSON Schema
Carregando… / Loading…
JSON to TypeScript, Zod, Go, Python and JSON Schema
Paste one or many JSON documents and generate TypeScript interfaces, Zod schemas, Go structs, Pydantic, dataclasses, C#, Rust, Java, Kotlin, Swift and JSON Schema. Samples are merged and every inference decision is shown.
Several samples become one type, with optionals, nulls and unions.
Writing the interface for an API response by hand is the classic job for a generator, but a single JSON document is misleading: a field that is filled in the sample may be missing in another, an integer may be a decimal on the next row, and a null does not say what the type was. That is why this tool accepts several documents (an array, one JSON after another, or a file with one object per line) and merges them into a single model. A field missing from any sample becomes optional (name?: string, omitempty in Go, Option in Rust, NotRequired in TypedDict). A null makes the field nullable (string | null, a pointer in Go, a nullable type with @SerialName in Kotlin). An integer and a decimal in the same field become a decimal. Genuinely different types become a union: string | number in TypeScript, z.union in Zod, anyOf in JSON Schema, an untagged enum in Rust and json.RawMessage in Go. Objects with the same shape share one type (shipping and billing become Shipping), and type names come from the keys, singularized when they are array items (items becomes Item, addresses becomes Address). The text of every value is inspected too: RFC 3339 date-times (2026-03-14T09:30:00Z), plain dates, UUIDs, emails, URLs and IPv4 addresses are tagged with a format, which produces z.uuid() and z.iso.datetime() in Zod, time.Time in Go, DateTimeOffset and Guid in C#, datetime and UUID in Pydantic, and format in JSON Schema. String fields with a few repeated values (at least 8 samples, at most 10 distinct values, each appearing about twice on average) become an enum. Objects whose keys look like data, such as numeric ids, UUIDs or dates, become a dictionary (Record<string, T>, map[string]T) instead of a type with hundreds of fields. Integers above 9007199254740991 (2^53 - 1) are flagged, because JavaScript reads them with lost digits, and mapped to int64, uint64 or json.Number. Keys that are not identifiers (user-name, 2fa, class) get a valid name in the target language plus the annotation that keeps the original key: a json tag in Go, JsonPropertyName in C#, serde rename in Rust, JsonProperty in Java, SerialName in Kotlin, CodingKeys in Swift and an alias in Pydantic. Everything runs in your browser: the JSON, which is often a real production response, never leaves the page.
How to use
Paste the JSON, pick a language and check the decisions.
Paste the JSON in the left field, open a file (.json, .jsonl, .txt, up to 10 MB) or use one of the examples. To improve the inference, paste more than one document: one after another, or inside an array.
Pick the language with the buttons. Turn on Compare side by side to see two targets at once, adjust the root type name and, under Options, naming style, native dates, immutability and per-language details.
Open Inference decisions to check what became optional, a union, an enum or a dictionary. Then copy the code or download the file. The copied link stores only the options, never your JSON.
Embed
Use this tool on your site
Paste the code into your HTML and the tool shows up on your page, without J-Kit's navigation and ads. It still runs in the browser of whoever visits your site.
<iframesrc="https://jkit.tools/embed/en-US/json-to-typescript"width="100%"height="600"style="border:0"loading="lazy"referrerpolicy="no-referrer-when-downgrade"title="JSON to TypeScript, Zod, Go, Python and JSON Schema"></iframe><p style="font-size:12px;margin:6px 0 0">Tool by <a href="https://jkit.tools/en/tools/json-to-typescript">J-Kit</a></p>
Cite
Cite or link to this tool
Using it in a paper, class or post? Copy the link or a ready-made reference. The access date is today's.
<a href="https://jkit.tools/en/tools/json-to-typescript">JSON to TypeScript, Zod, Go, Python and JSON Schema</a>
References
Sources and references for this tool
These references help contextualize formulas, standards, APIs and limitations used on this page. They do not replace professional validation when a result has legal, financial, medical or operational impact.
A field is optional when it is missing from at least one of the objects observed at that position, whether in different documents or in different items of the same array. If every object in a 50-item array has the key phone, it is required; if one does not, it becomes phone?: string. A null value does not make the field optional: it makes it nullable (string | null). The two concepts are different in APIs and in languages, so the tool keeps them apart. The All fields optional switch marks every field optional, which is useful for PATCH bodies and partial responses.