JSON to TypeScript
Turn an API response into useful TypeScript definitions. Provide several examples to help distinguish optional fields and mixed value types.
Load an example or paste your data to begin.
How to use JSON to TypeScript
- Paste an API response or an array of example documents.
- Name the root type; enable Multiple samples only when the array contains separate examples.
- Generate, review the inferred contract and download your TypeScript file.
What to expect
Generated types describe your examples, not every possible server response. Missing properties across multiple samples become optional. Strings remain strings, including date strings. Inputs that cannot be safely represented as JavaScript numbers are rejected rather than rounded.
Related tools
JSON to TypeScript FAQ
What is the difference between an array and multiple samples?
Normally an input array creates an array type. Multiple samples instead treats each item as an independent example of the same root type.
Does an interface validate incoming data?
No. TypeScript types are erased at runtime. Use the Zod generator when you also need runtime validation.
Does this tool upload my data?
No. Your input and generated files are processed on your device. No account is required.