How the types are inferred
- Strings, numbers and booleans map to
string,numberandboolean;nullstaysnull. - Each nested object becomes its own interface, named after its key in PascalCase. Array items get a singular name:
ordersbecomesOrder[]. - All objects in an array are merged. A key missing from some of them becomes optional (
coupon?: string), and a key with different types becomes a union (number | string). - An empty array becomes
unknown[], because there is nothing to infer from. - Keys that are not valid identifiers, like
first-name, are quoted.
One sample is not a schema
The types describe the JSON you paste. If a field can be null or missing in other responses, paste an array with several examples so the tool can see the variation, or adjust the output by hand. For runtime validation, pair the types with a schema library such as Zod.