Draft API response models
Supply representative nested objects, variants and null values. Review proposed names and which fields the provider truly guarantees.
Infer TypeScript interfaces, types, Zod schemas or JSON Schema from objects and arrays in sample JSON. Local generation in your browser.
Turn sample JSON into TypeScript interfaces or type aliases, Zod schemas or JSON Schema. The generator traverses nested objects and every array entry instead of observing only the first one. Output is a starting point to review against your API: one sample cannot reveal every value a service may return. Inference stays on your device and generated code is not executed inside the form.
The engine identifies strings, numbers, booleans, objects, arrays and null. Different observed types can form a union. TypeScript numbers use number; date-like and email-like strings remain string without guessed business rules. An empty array reveals nothing about its future entries, so its item type is unknown.
Within an array of objects, observed properties are combined. A field missing from some entries can become optional. Force-required mode creates a stricter contract, even when some supplied examples would then fail it. A property present with null is not absent: nullability and optionality are separate facts.
Choose interface or type for TypeScript declarations, Zod for validation code to integrate, or JSON Schema for a schema document. readonly applies to TypeScript declarations rather than runtime object freezing. Zod output imports zod, which your project must provide, and declares child schemas before parent references.
Targets share inference without promising identical behavior in every context. TypeScript checks development code rather than automatically validating network responses. Zod requires an actual validation call in your application. Generated JSON Schema closes objects using additionalProperties: false, so handling extra keys needs an explicit decision.
Paste or import valid JSON. Avoid unnecessary personal data: inference mainly needs structure and the different observed types.
Name the model and select output. Adjust missing-field handling and readonly when TypeScript output permits it.
Check unions, optional properties and dependencies before copying or exporting. Editing inputs or options hides old output. Compile or validate in your own project afterward.
Supply representative nested objects, variants and null values. Review proposed names and which fields the provider truly guarantees.
Generate basic schemas, then add application formats, limits and rules. A plain string is not automatically assumed to be a valid URL.
Place comparable objects in an array to expose fields appearing only in some cases. Include known uncommon situations.
With root name Response and interface output, user becomes a separate User model. id is number and name is string; types do not freeze the sample’s literal values.
Input
{"user":{"id":1,"name":"Ada"}}Result
export interface Response {
user: User;
}
export interface User {
id: number;
name: string;
}With root name Root and Zod output, ChildSchema precedes RootSchema, avoiding a reference to a constant before initialization.
Input
{"child":{"id":1}}Result
import { z } from 'zod';
export const ChildSchema = z.object({
id: z.number(),
});
export type Child = z.infer<typeof ChildSchema>;
export const RootSchema = z.object({
child: ChildSchema,
});
export type Root = z.infer<typeof RootSchema>;No. TypeScript describes expected values during development. To check received data at runtime, add a validator and actually use its result before trusting the response.
Objects within one array are compared for keys missing from some entries. A single object always containing a field cannot reveal that the field may sometimes be omitted.
A sample provides a string rather than proof of its business rule. The generator avoids turning appearance into arbitrary validation; add the required formats and constraints explicitly.
This tool offers several targets and naming or optional-field options. The standalone tool directly generates a schema and distinguishes observed integers. Both use the same shared inference engine.
Related tools
Tools similar or complementary to this one.
Generate a JSON Schema from a JSON example locally in your browser.
Validate a JSON document against a schema and locate every error precisely.
Generate realistic fake datasets in JSON, CSV or SQL.
Understand ISO 8601 week numbers, Unix timestamps in seconds or milliseconds, and the difference between human-readable dates and technical time values.