Skip to main content
KalkuNet

JSON to TypeScript — Generate Interfaces from a JSON Sample

Infer nested TypeScript interfaces and array element types from sample JSON.

Runs in your browserDeveloper · JSON, YAML, TOML, XML & CSV Converters
  • Types are inferred from the sample: keys missing from some array items become optional (?), mixed values become unions and identical shapes share one interface.

When to use the JSON to TypeScript Interface & Type Generator

  • Array items merged

    Every array item is read, not just the first. Keys found in only some items become optional properties, and values of different types become unions such as string | number.

  • Nested interfaces with clear names

    Nested objects get their own interface named after the key, and array items use the singular, so endpoints becomes Endpoint. Identical shapes share one interface.

  • Checked with the TypeScript compiler

    The output is verified with the TypeScript compiler in strict mode: the JSON sample type-checks, while values with a changed type are rejected, so the types are not just any.

  • A style that fits your code

    Pick interface or type, exported or not, and the root type name. Keys that are not identifiers, such as content-type, are quoted automatically.

Frequently asked questions

What about big numbers such as 19-digit IDs?

They are typed number, with a warning that JSON.parse will round them; for such IDs, string or bigint is usually safer.

Are dates recognized?

No. JSON has no date type, so values such as "2026-11-23" stay strings.

Can I use it for API responses?

Yes. Paste a real response from curl or DevTools, copy the types into your project and adjust the names.

Is my JSON uploaded?

No. The types are generated in your browser.

What if responses have different shapes?

Paste several responses as one JSON array. The items are merged, so properties that do not always appear become optional and properties with different types become unions, as happens with real data.

Learn more