Skip to content
yutils
Example

Input (JSON)

{
  "id": 1,
  "name": "yutils",
  "active": true,
  "owner": { "email": "hello@yutils.dev", "verified": false }
}

Output (TypeScript types)

interface Root {
  id: number;
  name: string;
  active: boolean;
  owner: Owner;
}

interface Owner {
  email: string;
  verified: boolean;
}

Note

Nested objects become separate interfaces. Arrays are typed from their first element. Mixed nulls produce union types.

Usage / FAQ

When to use

  • Generate TypeScript types directly from a JSON API sample
  • Convert Postman / cURL results into ready-to-paste type code
  • Seed initial types when mocking an external SDK
  • Skip writing types by hand for a quick first draft
  • Auto-split deeply nested objects into named interfaces

FAQ

Q.How are interfaces named?
A.Top-level is `Root`; nested objects use the PascalCase form of their parent key. Rename in your editor afterwards if you prefer.
Q.Are optional fields detected?
A.A single JSON sample assumes every field is present. For union / optional inference across multiple samples, edit the result manually.
Q.Can it produce Zod or io-ts schemas?
A.Only plain TypeScript interfaces today. If you need runtime validation, convert the result into a Zod schema as a separate step.
Fun facts
  • TypeScript was announced by Microsoft's Anders Hejlsberg in 2012 — the same person who built Turbo Pascal (1983), Delphi (1995), and C# (2000). Critics dubbed it 'C# for JavaScript,' but the genuine motivation was 'JavaScript doesn't scale to large codebases.'

    Wikipedia — TypeScript history
  • TypeScript uses structural typing (duck typing) — compatibility is determined by shape (properties, methods), not by the class name like Java/C#'s nominal typing. That's why interfaces inferred from JSON map cleanly onto runtime objects.

    TS Handbook
  • JSON → TypeScript inference falls down on never-seen cases. Is an empty array `[]` an `unknown[]`? `never[]`? `any[]`? Good generators use context (key names, sibling samples), but the deterministic answer ultimately needs human judgment.

    TS — Everyday Types