Why Generate Types From JSON?
Hand-typing TypeScript interfaces from a 200-line API response is tedious and error-prone. Our generator infers accurate types straight from a real payload — capturing every nested object, every optional field, and every mixed-type array your runtime actually sees.
Smart Inference
Each nested object becomes its own named interface, arrays of objects with varying shapes get merged into a single type, and heterogeneous arrays render as union types — never lazy any[].
Key Features
interface declarations — reusable across your codebase.
interface declarations or type aliases to match your project conventions.
Pro Tip
The generator can only see what's in your sample — fields that are null or omitted in the payload will be typed as null or skipped entirely. After generating, scan for null fields and broaden them (e.g. string | null) where the API spec says they're optional.
Walkthrough: Typing a REST Response
Capture a real response from your API in DevTools, paste it in, set the root type name to something like UserResponse, and click Generate. You'll get an export interface UserResponse at the top with named sub-interfaces for nested objects (Address, Friend, etc.). Drop the file into your types/ folder and import it from your fetch wrapper — instant end-to-end type safety.
Frequently Asked Questions
What happens with mixed-type arrays?
An array containing strings and numbers becomes (string | number)[]. Arrays of objects with different shapes get their fields merged into one interface with union types per field.
How are object keys with hyphens or spaces handled?
Non-identifier keys are emitted as quoted property names — 'kebab-key': string; — so the generated type compiles cleanly.
Can I regenerate types when the API changes?
Yes — just paste the new payload and click Generate. Use JSON Diff first if you want to see exactly which fields changed.
Does it generate validators or runtime guards?
No — only static TypeScript types. For runtime validation, pair the output with a library like Zod or io-ts using the same field shapes.