(Nasa Ingles ang dokumentasyon)
What it does
Generate a Zod validation schema from JSON. Scalars map to their validator (z.string, z.number, z.boolean, z.null), objects recurse into inline z.object({...}), arrays become z.array(...) — and a mixed-type array becomes z.union([...]) of each distinct element type. Drop the output straight into a TypeScript project that uses Zod for runtime validation: API responses, config files, form payloads, fixtures. 100% client-side.
How to use it
- Paste JSON into the JSON box (a sample is prefilled — Sample restores it, Clear empties it).
- Optionally set a Root name (defaults to
Root, used for theconst Root = ...binding). - The schema renders live on the right, pinned while you scroll the input.
- Copy it, or Download it as
schema.ts.
Examples
A flat object — {"id":1,"name":"Ada","active":true,"tags":["a","b"]} →
const Root = z.object({
id: z.number(),
name: z.string(),
active: z.boolean(),
tags: z.array(z.string()),
});
Nested objects recurse inline — {"user":{"name":"Ada"}} →
const Root = z.object({
user: z.object({
name: z.string(),
}),
});
Mixed arrays become array-of-union — {"xs":[1,"a"]} →
const Root = z.object({
xs: z.array(z.union([
z.number(),
z.string(),
])),
});
Edge cases — empty arrays become z.array(z.unknown()); null maps to z.null(); anything the parser rejects shows in the error box instead of the schema.
Good to know
- Private: parsing is local — safe for sensitive payloads.
- The generated schema is a starting point: add
.min()/.max()refinements where your real data has constraints the sample didn’t show. - Related tools: JSON to TypeScript, JSON Validator.