Create TypeScript types from real JSON examples
- Paste a JSON object, array, or primitive value into the input.
- Review the inferred TypeScript interface or type alias. Check optional properties and unions against your API contract.
- Copy the output into your project. Switch format to compare compile-time types and runtime validation.
Interfaces, arrays, and primitive roots
Object samples generate an interface. An array, string, number, boolean, or null at the root generates a type alias. Use the Zod tab when the response also needs validation at runtime.
// JSON input: [1, "pending", null]
export type Root = Array<number | string | null>;How arrays and optional fields are inferred
Every array element is inspected. For [{"id":1},{"id":2,"name":"Ada"}], name is optional. Mixed value types become unions. An empty array uses an unknown element type until an example supplies more information.
Continue the workflow
Use API response fixtures as examples, then exercise your schema with the mock data generator. Read the JSON-to-Zod validation guide for a complete example.