JSON to TypeScript & Zod
Turn a representative JSON sample into TypeScript interfaces and Zod schemas. Inference is based on the sample, so review optional fields and unions against your real API data before shipping.
Runs in your browser - files are never uploadedJSON to TypeScript & Zod
Generate TypeScript interfaces and Zod schemas from a JSON sample.
Choose files from your device
Tip: paste an image with ⌘/Ctrl + V
Example: generated output
From a sample object containing nested data, a mixed array and a nullable field:
TypeScript
export interface ApiExampleCandidateProfile {
country: string;
verified: boolean;
}
export interface ApiExampleCandidate {
id: number;
displayName: string;
active: boolean;
roles: string[];
profile: ApiExampleCandidateProfile;
}
export interface ApiExample {
candidate: ApiExampleCandidate;
audit: null;
}Zod
import { z } from 'zod';
export const ApiExampleCandidateProfileSchema = z.object({
"country": z.string(),
"verified": z.boolean(),
});
export const ApiExampleCandidateSchema = z.object({
"id": z.number(),
"displayName": z.string(),
"active": z.boolean(),
"roles": z.array(z.string()),
"profile": ApiExampleCandidateProfileSchema,
});
export const ApiExampleSchema = z.object({
"candidate": ApiExampleCandidateSchema,
"audit": z.null(),
});
export type ApiExample = z.infer<typeof ApiExampleSchema>;Generated types reflect only supplied sample data. Check optionality and mixed types against representative inputs.
How to use it
- Paste one JSON object or array of objects.
- Choose a root type name and optional-field behavior.
- Generate, review, copy or download the TypeScript and Zod code.
Frequently asked questions
Can one example reveal every optional field?
No. Fields missing from the provided sample cannot be inferred; provide representative samples or edit the generated output.
Does it support nested data?
Yes, nested objects and arrays are recursively converted. Mixed sample types are represented as unions where possible.
Is the sample uploaded?
No. Generation runs locally.