2026-10-03
You have a JSON response from an API and a TypeScript file that needs to describe it. Typing a nested payload by hand takes ten minutes and a typo or two, so most people reach for a generator: quicktype, transform.tools, or one of the many "JSON to TS" web pages. The catch is the same as with other online tools: the sample you paste is often a real response, with real names, emails and IDs in it.
iLoveDevTools's JSON to TypeScript does the inference in your browser tab with plain JavaScript. The JSON is parsed locally and no request is made with it.
Objects become named declarations. A nested object under the key address gets its own Address type, and an array under orders produces an Order type for its items. Keys that are not valid identifiers, such as content-type, are quoted. Identical shapes are reused rather than declared twice.
Arrays are merged. Every element is folded into one element type, so [{"id":1},{"id":2,"coupon":"X"}] becomes an item type with id: number and coupon?: string. If the same key holds different types in different elements you get a union, like string | number.
Nulls become unions with null, listed last. An empty array has nothing to learn from and becomes unknown[].
Options. Choose interface or type, set the root name, and toggle export, readonly and optional fields.
A sample is only a sample. If a field is a number in your example but sometimes a string in production, the generated type will not say so. If a field is always present in your sample but optional in the API, the type will claim it is required. Treat the output as a first draft and check it against the API documentation, or feed it a sample that covers the variations. Numbers are always number: there is no way to tell an integer from a float or an ID from a timestamp, and dates arrive as string.
quicktype. quicktype is the most capable tool in this space. It reads multiple samples, supports JSON Schema and many output languages, and has a command-line version and an editor extension. If you need other languages, schema input, or generation in a build step, use it. This tool only does TypeScript and works from a single JSON sample, in exchange for needing no install and no upload.
transform.tools. A handy multi-format converter that also runs in the browser. It covers many conversions at once; this page focuses on TypeScript and exposes the options above.
Schema-based generators. If the API publishes an OpenAPI or JSON Schema document, generating types from that is more reliable than inferring them from an example, because the schema states what is optional and what the allowed values are.
For the everyday job of turning one real response into a starting set of types, try JSON to TypeScript. If you also need to tidy or validate the payload first, JSON Tools does that, and the Data Format Converter converts it to YAML or XML.