JSON to TypeScript Interface Generator
Turn a sample JSON object into TypeScript interfaces or type aliases.
About this tool
Paste a sample JSON object or array and get matching TypeScript interface declarations (or type aliases), including nested objects and arrays. This saves the tedium of hand-writing types for an API response or config file you already have real data for.
Types are inferred from a single sample — if a field is sometimes a different type or missing in other real responses, double-check the generated type against your actual data. The result is syntax-highlighted (toggle "Raw" for a plain copyable textarea); everything runs locally in your browser.
Frequently asked questions
- How are arrays typed?
- An array of objects is merged into one nested interface using the union of keys seen across its elements — keys not present in every element are marked optional (
?). An array of primitives (numbers, strings) becomestype[], or a union like(string | number)[]if the values are mixed. - What happens with
nullvalues? - A field that is
nullin your sample is typed asnull— you'll likely want to widen it manually to something likestring | nullonce you know the field's real type from other samples. - Why does a property name have quotes around it in the output?
- JSON keys that aren't valid TypeScript identifiers (containing spaces, starting with a digit, etc.) are automatically wrapped in quotes, since TypeScript requires that for such property names.
- Is my JSON uploaded anywhere?
- No — parsing and type generation both happen entirely in your browser.