JSON to TypeScript infers TypeScript interfaces from one JSON sample after JSON.parse. Nested objects become interfaces. Arrays become T[]. Unions appear only when array items in this sample have different JSON types. The tool runs in the browser. Nothing is uploaded.
This is not a schema language and it is not a full TypeScript compiler. It does not mark fields optional, because a single sample cannot tell you what was omitted. Keys present in the sample are required in the interface. If a later payload drops a field, TypeScript will complain — that is the point of a starting type, and also the limit.
Invalid JSON is not converted. Root arrays, objects, and primitives are all legal. A root string becomes export type Root = string.
{
"user": {
"id": 1,
"name": "Ada"
},
"tags": ["admin"]
}
You should get a User interface with id: number and name: string, and a Root with user: User and tags: string[]. Interface names come from key names. Colliding names get a numeric suffix.
Use this when you have one API body and want a first TypeScript shape before you write a real contract. If you only need field names, use the JSON Key Extractor. If you need to walk nesting visually, use the JSON Viewer, then generate types.
Nested objects get their own export interface so you can import User in tests. Array objects use a name built from the parent key plus Item, for example TagsItem only if tags held objects. String arrays stay string[] and do not create an interface. Two different objects that share a name stem get a numeric suffix rather than being silently merged.
Root arrays emit the item interfaces plus export type Root = …[]. Root primitives emit only that type alias. HTML-like strings stay string. They are not parsed as JSX. true and false are boolean. JSON null as a property value is the type null for that property in this sample.
Do not paste a TypeScript object literal. The parser is JSON.parse. Unquoted keys and trailing commas fail the same way they fail every other JSON tool on this site. After you copy the output, rename Root to match the endpoint if you want a stable export. The generated names are a convenience, not an API branding step. Review the interfaces before you commit them to a shared package.
number.null becomes the TypeScript type null, not T | null, unless it appears beside other types in an array union.When the next API body fails the draft types, see turn an API JSON response into TypeScript types.
Parse and inference run in this browser. The payload is not sent to YallaSolve for this tool.
Infers interfaces from one JSON sample. Keys present in the sample are required. Optional fields, generics, and comments are not guessed.
The tool only sees one sample. A missing field in another payload cannot be inferred. Edit the interface if a key is optional.
No. It prints interfaces and types. Paste them into your project and compile there.
Item types from this sample are unioned. Empty arrays become unknown[].
No. Output is TypeScript interfaces and a Root type when needed.