// Paste JSON on the left
// Paste JSON on the left
Turn a real API response into types you can actually commit. Paste the JSON, get named interfaces for every nested object, with optional properties inferred from the data rather than guessed.
Writing an interface by hand from a sample response is mechanical work with one trap in it: the fields that happen to be null or absent in the sample you copied. A generator that only sees one object will type those as null or omit them, and the error surfaces later against real data.
This page infers from every object in an array rather than the first one, so a field missing from some elements becomes optional and a field that is a number in one and a string in another becomes a union instead of a guess. Nested objects become named interfaces rather than inline shapes, which is what makes the result something you can actually paste into a project.
A generated interface is a description of the sample, not a contract with the server, and the distinction decides how much to trust it. Anything the API can return but did not happen to return in the response you pasted is invisible: an error shape, a field that appears only for administrators, an array that is empty here and full of objects in production. Widening the sample — several responses concatenated into an array — is the cheapest way to catch those, and it is exactly what the multi-object inference here is for.
Numbers deserve a second look before the result is used. JSON has one numeric type and TypeScript has one too, so an integer identifier and a floating-point price are both typed as number, which is correct and hides a real problem: JavaScript numbers lose precision above 2^53, so a 64-bit identifier arriving as a JSON number is already wrong before any typing happens. APIs that know this send such identifiers as strings, and a field typed as string where you expected a number is usually the server being careful rather than a mistake.
Dates are the other place where the type is honest and unhelpful. An ISO timestamp is a string as far as JSON is concerned, so it is typed as string — and it should be, because that is what the parser hands back. Turning it into a Date is a decision for the code that consumes the response rather than something a generator should assume, and marking it in the interface with a branded type or a comment is more useful than pretending JSON.parse produces a Date object.
Because every sample for that key was null. JSON has no type information for a null, so anything more specific would be a guess. Paste a response where the field is populated and the real type appears.
Not yet — output is TypeScript interfaces or type aliases. The generated shape maps cleanly onto most language model classes if you need to translate it by hand.
Yes. A parse failure is reported inline with the message from the JSON parser, so you can fix the payload before worrying about the types.