Start from representative JSON
Open the JSON to TypeScript Type Generator and paste a response object or an array of representative objects. A single sample can describe fields that exist in that example; multiple objects reveal which fields may be absent. Use realistic examples from the API contract, and remove personal or production secrets before sharing a screen.
Infer optional fields from a sample array
Keep Treat a top-level array of objects as multiple samples enabled when the array contains separate response examples. If `email` appears in two of three objects, the inferred property is optional. The tool applies the same presence check to nested objects. Turn this option off when the array itself is the value you want to model, such as a list returned by an endpoint.
Review nested values and unions
Inspect nullable values, arrays, and mixed samples. A property that is sometimes null becomes a union with `null`; an empty array becomes `unknown[]` because it contains no evidence about its element type. JSON numbers map to TypeScript `number`, so the output does not distinguish integers from decimals.
Choose and use the root declaration
Give the root type a valid TypeScript identifier, then choose an interface or type alias. Copy the generated code into the module that owns the API response type, or download a `.ts` file. Generated property names are quoted so keys containing spaces or punctuation remain valid TypeScript.
Treat inference as documentation, not validation
Generated types describe the samples you supplied. They cannot prove that another response has the same fields or types, and TypeScript annotations do not validate JSON at runtime. Compare the output with the API schema; use a runtime validation library in your application when incoming data must be checked.
Keep the workflow private and reproducible
Parsing occurs in the browser tab with no upload or API call. The input is limited to 100 KB. Save a non-sensitive example response and the generated type with your project so future API changes can be reviewed against the same sample. The generated code is a starting point, not a substitute for a maintained API contract.