JSON

JSON to TypeScript

Turn a representative JSON sample into a named TypeScript type for a draft interface.

How this tool works

Nested objects and arrays become typed structures. Different observed values form unions, and a property absent from some observed array objects becomes optional.

Example-driven inference cannot discover values or fields absent from the sample. Review generated types against the real API contract.

Examples

  • Infer a nested order response.
  • Observe optional fields across array elements.
  • Preserve null as a union member.

Common use cases

Bootstrap a typed fixture during client development.

Worked synthetic example

Valid example

{"order":{"id":7,"note":null}}

Expected: An Order shape with numeric id and null note. The type reflects only the supplied sample; another note value would change the inferred union.

Failure or warning to recognize

Warning / interpretation

A single example omits a field that exists in real responses.

Expected: A sample missing a real response field still generates a type without that field; compare it with the API contract.

Related guides

Official references

Related tools

JSON to TypeScript: Draft types from a JSON sample | DevPouch