Generate TypeScript interfaces from a JSON payload, with named interfaces for nested objects.
A null value produces the null type, since there is no way to know the intended type from one sample.
Use a real response rather than a hand-written example. The types are inferred from the data you paste, so a realistic payload produces types that match production.
Give it the name you would use in your code, such as User or OrderResponse. Nested objects get their own interfaces named after the field they came from.
The result is ready to paste into a types file. Keys that are not valid identifiers are quoted, and arrays get element types rather than being left as any.
No. Everything runs in your browser, which matters because the fastest way to get good types is to paste a real API response, and those often contain customer data.
Because the sample had null in it and a single example cannot say what the type should be when it is not null. Change it to the real type, usually a union such as string or null.
An array containing more than one shape produces a union of the element types, so nothing is silently widened to any and you can see the inconsistency in your data.
Not from a single sample, because a field that is simply absent cannot be distinguished from one that is never sent. Add question marks yourself where the API documents a field as optional.
It emits interfaces, which are the usual choice for object shapes and can be extended and merged. Changing the keyword to type is a find and replace away if you prefer.
JSON has no date type, so an ISO timestamp is inferred as string, which is accurate. Convert to Date in your own code after parsing.
They come from the field names, with plural fields turned singular for array elements. Rename them freely; the generator is a starting point, not the final file.
Yes, completely free with no sign-up and no size limit.
Free online JSON formatter and validator. Format, minify and validate JSON with syntax highlighting and instant error detection.
Open ToolTurn a spreadsheet export into JSON, with quoted fields, custom delimiters and automatic type detection.
Open ToolConvert config files in both directions, covering nested maps, lists, comments and block scalars.
Open Tool