Skip to content
BEAD

JSON → TypeScript

Turn any JSON sample into TypeScript interfaces — handles nested objects, arrays of varying shape, and optional fields.

TypeScript
interface Specs {
  weight_g: number;
  battery_hours: number;
}

interface Review {
  user: string;
  stars: number;
  comment?: string;
}

interface Root {
  id: number;
  name: string;
  active: boolean;
  tags: string[];
  specs: Specs;
  reviews: Review[];
  discontinued: null;
}

🔒 Type inference runs entirely in your browser.

How inference works

  • Objects become named interfaces, lifted out and named after the field they came from (so a user field yields a User interface).
  • Arrays of objects are merged into a single shape — fields missing from any element become optional.
  • Arrays of mixed primitives become a union ((string | number)[]).
  • Empty arrays become unknown[]; null values widen the field type with | null.

Always sanity-check the output for very dynamic JSON — a single sample can't reveal every possibility.

You might also like