Turn a JSON sample into TypeScript interfaces, Go structs or Python dataclasses. Detects optional fields across array items. Free, runs in your browser.
First time here? Paste a JSON object or array Your input is processed locally and disappears when you close the tab.
Hand-writing an interface for an API response you have already got in front of you is pure transcription, and easy to get subtly wrong. This free json to typescript converter reads a sample and generates the types for you — in TypeScript, Go or Python.\n\nThe part worth caring about is optionality. When your sample array contains objects with slightly different keys, the tool compares them all and marks anything missing from some records as optional. That reflects how APIs actually behave, and it is the single biggest reason to paste several representative records rather than just one.\n\nNested objects become their own named interfaces rather than inline blobs, and plural keys are singularised, so a posts array produces a Post interface. Mixed arrays become properly parenthesised unions — (number | string)[] rather than the subtly wrong number | string[], which means an entirely different thing.\n\nOne honest limit: inference works from the example you give it. It cannot know that a field which happens to be null in your sample is a string in other responses, or that a status number is really an enum. Treat the output as a strong first draft. Everything runs in your browser, which matters when the sample is a real API response containing real data. Pair it with the JSON Formatter to tidy the input first, or JSON Diff to compare two payloads.
Paste a JSON object or array
Choose TypeScript, Go or Python
Name the root type
Copy or download the generated types
Optional fields are inferred from your sample. When an array contains objects with differing keys, anything missing from some of them is marked optional. That is why a realistic sample with several array items produces much better types than a single record.
Inference works from one example, so it cannot know that a field which happens to be null here is a string elsewhere, or that a number is really an enum. Treat the output as a strong first draft rather than a finished contract.