{ } 2DevKit
Tools / Data & JSON

JSON to TypeScript

Generate a TypeScript type alias from JSON examples with nested objects, arrays and union types, locally and privately.

Generates a type alias from the supplied JSON example. Array element shapes become a union; this is an inferred model, not a complete schema.

Everything runs locally in your browser.

What is JSON to TypeScript?

Converting sample JSON into TypeScript types can speed up API client prototyping. This generator infers primitive, object and array types and creates unions when sample array members differ. Because it uses only a sample, it cannot infer optional properties that were absent from the input or guarantee compatibility with unseen responses.

How to use this tool

  1. Paste a valid JSON example and choose a legal TypeScript type name.
  2. Convert to generate a TypeScript export type declaration.
  3. Copy the declaration or download it as a .ts file.

Example

{"name":"Ada","score":10} → export type GeneratedType = { name: string; score: number; };

Related developer tools