Paste any JSON and get TypeScript interfaces instantly. Nested objects become named interfaces, arrays of objects are typed correctly, and nullable fields are reflected in the output.
Every JSON object becomes a TypeScript interface. Nested objects generate additional interfaces named after the key. Arrays of objects generate an interface for the element type, with the key name singularized.
Input JSON:
{
"user": {
"id": 1,
"name": "Alice",
"active": true,
"address": { "city": "Springfield", "zip": "12345" },
"posts": [
{ "id": 101, "title": "Hello World" }
],
"avatar": null
}
}
Generated TypeScript:
interface Root {
user: User;
}
interface User {
id: number;
name: string;
active: boolean;
address: Address;
posts: Post[];
avatar: null;
}
interface Address {
city: string;
zip: string;
}
interface Post {
id: number;
title: string;
}
Interface naming follows a simple rule: the key name is capitalized. Arrays use the singularized key name — posts → Post[], categories → Category[].
Type inference works from the values the JSON actually contains.
Primitives map directly: strings become string, numbers become number, booleans become boolean, null becomes null. Arrays of a single type produce typed arrays — ["a", "b"] becomes string[], [1, 2, 3] becomes number[]. Mixed arrays (integers and strings together) produce Array<string | number>.
Arrays of objects are merged into one interface. If you have ten user objects in an array, the generator examines all of them together — fields that appear in every element become required, fields that only appear in some become optional with ?.
Null fields can only type as null from a single sample. The tool cannot tell that a field is sometimes a string and sometimes absent — that inference needs a schema. Widen those types manually after generating.
Empty arrays type as unknown[] since there is no element to learn a type from.
Type inference from a single JSON sample is inherently limited. A few patterns come out of the generator needing manual cleanup.
Null fields are the most common case. A field that is null in the sample types as null rather than string | null. The tool can only see what is in the input — you will need to widen those types yourself based on knowledge of the actual schema.
Discriminated unions do not generate correctly. If an array contains objects with a type field that determines their shape, the generator merges all shapes into one interface with optional fields. Splitting these into a proper TypeScript discriminated union is a manual step.
Name collisions happen when two different parts of the JSON use the same key for nested objects — both user.address and company.address resolve to an Address interface, and the first one encountered wins. Rename the conflicting interface after generating.
Objects with dynamic string keys come out as explicit field interfaces rather than [key: string]: T index signatures. For dictionaries and maps, switch to an index signature manually.
A field whose value is null in the JSON types as null. Since a single sample can only show one value, the tool cannot infer that the field is sometimes a string. Widen these types manually: change null to string | null where appropriate.
All objects in the array are merged into a single interface. Fields present in some elements but not all become optional (marked with ?). The interface name is the singularized, capitalized version of the key — posts → Post, categories → Category.
An empty array has no elements to infer a type from, so the output is unknown[]. Add at least one element to the array and re-generate.
Yes, for most cases. The generated interfaces are valid TypeScript. You may need to add export keywords, adjust nullable types, and split discriminated unions. For simple API responses the output is typically paste-ready.
Yes. Each nested object generates its own interface recursively to any depth. The interfaces are emitted in order: Root first, then child interfaces in the order they were encountered.
No. The entire conversion runs in your browser with no network requests. Nothing is transmitted.
More Tools