How to use the JSON to TypeScript converter
Paste a sample API response and get TypeScript interfaces shaped to match it. It is a useful starting point when an external API ships no types, or when there are simply too many fields to transcribe by hand.
The inference rules are these. Strings become string, numbers become number, and true or false becomes boolean. null stays the null type; if a real value can appear there, widen it yourself to something like string | null. An empty array becomes unknown[], because a sample with nothing in it cannot say what belongs there. An array of mixed kinds is joined into a union such as (number | string)[].
A nested object is never inlined; it is split into its own interface. The name is the key converted to Pascal case, and a plural key stays plural rather than being guessed into a singular. Colliding names get a number appended, and the result reports how many were renamed that way. An array made entirely of objects is merged into one interface using the union of every element's keys, and a key that only some elements carry is marked optional with a question mark. Keys that are not valid identifiers are quoted.
What it does not do is stated just as plainly. A date-looking string is not turned into Date, and a field with a fixed set of values is not narrowed into an enum or a literal union. JSON with comments cannot be read, and a malformed document reports the exact position where parsing failed. Treat the output as a draft meant for a quick human pass.
Frequently asked questions
A sample with no elements carries no information about what belongs inside. Convert a sample that has at least one element, or write the type yourself.
It is added to keys that only some elements of an object array carry. Turn the option off to make every key required; the count is reported above the output.
No, they are always split into separate interfaces because that is easier to reuse and edit. Paste an interface back inline yourself if you prefer that shape.