How the types are inferred
The converter walks your JSON and maps values to TypeScript types: strings, numbers, booleans, null, arrays, and objects. The judgment calls are documented here so you know exactly what you're getting:
- Nested objects become named types. A key
addressholding an object produces anAddressinterface;billing_addressproducesBillingAddress. Objects inside arrays get singular-ish names:users: [...]produces aUsertype. If two different keys produce the same name with different shapes, a numeric suffix keeps them distinct. Prefer everything inline? Toggle "Inline nested objects". - Arrays infer a union of element types.
[1, "a"]becomes(number | string)[].[]— an empty array with nothing to learn from — becomesunknown[], which is the honest answer (and safer thanany[]: you must narrow it before use). - Optional fields are detected across array samples. This is the big one. If your array of objects has
nicknamein three items but not the fourth, the merged element type getsnickname?: string. A field that's present but sometimesnullgetsstring | nullinstead — presence and nullability are different facts, and the output preserves the distinction. - Keys that aren't valid identifiers are quoted.
"content-type"becomes"content-type": string— no invalid output. - No
any, ever. When the converter can't know (empty arrays, explicit nulls with no other evidence — emitted asnull), it says so in the narrowest honest type rather than giving up the type checker's protection.
One inherent limitation of sample-based generation is worth stating plainly: the type describes your sample, not the API contract. If the sample happens to omit a field that's usually present, or a number field happens to be an integer in every sample you pasted, the generated type reflects that. Paste a response with multiple array items — or several representative responses wrapped in an array — and the merger does noticeably better.
JSON Schema input — what's supported
If you paste a JSON Schema instead of a JSON sample (detected by $schema, or a type/properties structure), the converter switches to schema mode and handles the basics: type, properties + required (unrequired properties become optional), items for arrays, enum (emitted as a union of literals), const, nullable via type: ["string","null"], and $ref to #/definitions/… or #/$defs/… within the same document.
Not supported, stated honestly rather than half-implemented: allOf/anyOf/oneOf composition, external $refs, patternProperties, conditional schemas (if/then), and format-driven refinements. If your schema uses those, the affected part is emitted as unknown with a comment naming the unsupported keyword — you'll see exactly where hand-editing is needed. For full-fidelity schema conversion, a dedicated compiler in your build pipeline is the right tool; this page covers the quick-look case.
Generated types are a starting point
Treat the output as scaffolding you review, not gospel. Things worth checking by hand: fields you know are enums but the sample shows as plain strings (tighten status: string to status: 'active' | 'archived'); date strings, which JSON can't distinguish from other strings (they arrive as string, not Date — parse at the boundary); and ID fields where you may want branded types. The generator gets you 90% of the way in a second; the last 10% is where your domain knowledge belongs.