Developer Tools
JSON to TypeScript — Interface & Type Generator
Generate TypeScript interfaces or type aliases from JSON samples in your browser. Handle nested objects, arrays, optional properties and unions, then copy the declarations.
Generate a starting point for TypeScript types from JSON. Limits: 100,000 input characters (UTF-16 code units), depth 64 (root = 0), 10,000 values, 500,000 output characters and 1,000 declarations. This tool does not send your input to a server. Page resources, analytics and ads may use the network.
Enter JSON to generate types.
The output is a set of type declarations. When export is off, place it in a module that already has an import or export, or add export {} to the file. In a global script, names such as Array or Node may conflict with existing types. Check for other name collisions in the same scope.
How inference works and its limits
Types are inferred from the observed values. A property missing from some objects in an array becomes optional; different observed types form a union. A null-only property stays null, even when made optional. An empty array becomes unknown[]; an empty object by itself becomes Record<string, unknown>.
Small-object inlining applies to child objects with at most two properties. readonly prevents property reassignment; it does not make array elements immutable. Array and primitive roots always use a type alias. Date strings remain string.
Unseen values and business rules cannot be inferred. Generated types do not validate or convert data at runtime, and number does not guarantee numeric precision or range. Formatting is independent of type options and declaration limits; it checks JSON syntax and input/output length while preserving number notation. For duplicate keys in one object, inference uses the last value. Review the types and numeric handling in your project.

