JSON to TypeScript types
Runs in your browser – nothing is uploaded.
Paste a sample JSON response to get TypeScript interfaces for it. Nested objects get their own named interfaces, and arrays of objects are merged into one item type.
A key that is missing from some items in an array becomes optional (?). Mixed values become unions such as string | number.
Example
Root type name: Root, Output: interfaces
Input
{"id":1,"name":"Ada","manager":null,"tags":["maths"],"projects":[{"title":"Engine","year":1843},{"title":"Notes"}]}Output
export interface Root {
id: number;
name: string;
manager: null;
tags: string[];
projects: Project[];
}
export interface Project {
title: string;
year?: number;
}Frequently asked questions
How accurate are the types?
They describe the sample you paste. A field that is null in the sample is typed as null, and an empty array as unknown[], so check them against real data or your API documentation.
Can it output type aliases instead of interfaces?
Yes. Set Output to “type aliases”.