JSON to TypeScript types
freeGenerate TypeScript interfaces or types from JSON with format-aware inference.
export interface Address {
street: string;
city: string;
country: string;
postalCode: string;
}
export interface Root {
/** @format uuid */
id: string;
name: string;
/** @format email */
email: string;
age: number;
bio: null;
address: Address;
tags: string[];
/** @format date-time */
createdAt: string;
verified: boolean;
}
Paste any JSON sample and get clean, ready-to-import TypeScript types. The converter walks the document once, names every distinct shape as a top-level interface (no anonymous nested pyramids), and infers optional fields by intersecting keys across array items. Format hints from the JSON Schema layer — `date-time`, `uuid`, `email` — surface as `@format` JSDoc comments so downstream tooling can pick them up.
Common use cases
- Modelling an API response. Drop a sample payload from a fetch call, copy the generated `interface`, paste into your codebase. The intersect-required-keys heuristic handles partial / optional fields correctly across mixed array items.
- Replacing `any` in a legacy codebase. Run a representative production payload through the converter and use the resulting types as the seed for migrating an existing `any`-typed integration.
- Locking down a config schema. Convert your `config.json` to a TypeScript type, then `as const` your runtime config and let `satisfies` catch drift between schema and values.
- Generating types for SDK clients. Use the `type` declaration style + `readonly` toggle to produce immutable-by-default types suitable for public SDK surfaces.
Frequently asked
Why is my array typed `unknown[]`?
An empty array gives the inferrer nothing to work with, so it falls back to `unknown[]`. Add a representative element to the sample and re-convert.
Can I rename the root type?
Yes — the Root field at the top of the options bar accepts any valid TypeScript identifier. It also propagates into the download filename so saved files match.
Why is a field marked optional when my sample always has it?
Optionality is inferred as the intersection of keys across all observed sibling objects (for arrays) or as 'present' for single objects. If you're seeing unexpected optionality, you likely have inconsistent keys across array items in your sample.
Does it support discriminated unions?
Not yet — currently sibling object shapes are merged into one union of optionals rather than split on a discriminator key. The codegen IR already detects literal string fields, so this is a planned follow-up.
What's the difference between `interface` and `type`?
Functionally equivalent for object shapes. `interface` supports declaration merging (multiple definitions augment each other) and tends to read better in error messages; `type` works for unions / mapped types. Pick by codebase convention.
Why are children declared before their parents?
Default is children-first so each type is declared above its first reference — easier to read top-to-bottom. Flip the toggle if you prefer Root-first (the convention quicktype uses).
Does the URL save my options?
Yes. Any non-default options are encoded as query parameters, so you can bookmark or share a link that opens the tool with the same configuration.