JSON Schema Generator
Turn sample JSON into TypeScript, Zod, and other schemas in seconds. Free online JSON-to-schema tool for API and frontend work.
How inference works from one sample
// Sample
{
"id": 1,
"name": "Ada",
"tags": ["a", "b"],
"meta": null,
"alt": ["x", 2]
}
// Typical TS sketch
type Sample = {
id: number;
name: string;
tags: string[];
meta: null; // often should be Something | null
alt: (string | number)[];
};Optional fields that are simply absent in the sample never appear. Unions only include types that showed up. Arrays of objects merge property sets heuristically — conflicting shapes get widened or dropped depending on the generator.
Limitations to expect
- No proof of max lengths, formats (email/uri), or numeric ranges
- Date strings look like plain string
- Empty arrays become
unknown[]orany[] - Zod output still needs
.optional()/.nullable()review
Frequently Asked Questions
Why did an optional field become required in TypeScript?
Inference from a single sample treats every present key as required. Missing keys in other real payloads are invisible unless you feed multiple examples or edit the schema.
How are mixed-type arrays handled?
Generators usually emit a union of observed element types (e.g. (string | number)[]). They cannot know undocumented variants that never appeared in the sample.
Can this replace handwritten domain types?
Use it as a bootstrap. Refine nullability, branded IDs, and enums by hand — sample JSON under-specifies business rules.