{
"color": "red",
"count": 2
}A sample response is enough to sketch the type you will parse into, with the limits of a single example written in the output. JSON to TypeScript walks the value. An object becomes export interface Root with one field per key. Field names are quoted, which keeps keys that would be awkward as bare identifiers. Strings are string, numbers are number, booleans are boolean, and null is null.
An array becomes export type Root = Array<...>. If the items have different types, those types are joined with a vertical bar. One object cannot show that a field is optional. count is number here even when a JSON Schema call types the same 2 as integer, because this output is TypeScript and the value is a JSON number. Nested objects are inlined.
{"color":"red","count":2}. For a row list, paste [{"Item":"Pen","Quantity":4}].
export interface Root { "color": string; "count": number; } The one-row array returns export type Root = Array<{ "Item": string; "Quantity": number; }>;
The interface matches the sample you pasted, quoted keys included, so the gaps you still have to mark optional are visible.
Quoted keys are legal for every JSON key, including keys with spaces or hyphens. You can remove the quotes when the key is already a safe identifier.
JSON Schema distinguishes integer from number. This page prints number for every JSON number, which is the TypeScript type you will actually hold.
export type Root = Array<{ ... }>. An array of different item shapes joins the item types with |.
Every key on the sample becomes a required field. A missing key in real responses will not appear. Add ? yourself for keys the sample happened to include every time.
The generated name is Root. Rename it after you copy. Nested objects are written inline rather than as extra interfaces.