๐ท JSON to TypeScript
TypeScript
interface RootObject {
id: number;
name: string;
active: boolean;
tags: string[];
address: {
city: string;
zip: string;
};
}Paste in JSON data and this tool automatically generates the matching TypeScript interface definition. Supports nested objects and arrays. Handy for quickly creating a type for an API response, or generating a type definition from existing JSON data.
How to use
- Enter a name for the generated interface (optional).
- Paste the JSON data you want a type definition for into the input field.
- The TypeScript interface is generated automatically โ use "Copy" to copy it.
FAQ
What happens if an array's elements have mixed types?
If an array contains multiple different value types, a union type is generated (e.g. (string | number)[]).
Is the generated type exactly correct?
It's a basic type inferred from the JSON values. In a real API, the same field might sometimes be null or undefined, so adjust fields to be optional (?) as needed.
Are dates or other special string formats detected automatically?
No, date strings (like ISO 8601 format) are also treated as a regular string type.