JSON to TypeScript
Generate TypeScript interfaces and types from any sample JSON. Handles nested objects, arrays, optional fields, and mixed types. Paste JSON, copy the interface.
How to use the json to typescript
Paste a JSON sample and click Generate. The result is a set of TypeScript interfaces and type aliases that match the structure. Larger or more varied samples produce more accurate unions.
Formula & explanation
We walk the JSON tree once, emit a TypeScript shape for each unique object structure, and wire arrays + unions automatically. Fields that vary between samples become optional.
Examples
{"id":1,"tags":["a","b"]} produces interface Root { id: number; tags: string[]; }
Frequently asked questions
- Can I paste an array?
- Yes — top-level arrays emit a type alias for the element type.
- What about nullable fields?
- Mix several samples that include and omit a field, and the inferred type becomes T | null.
Related developer tools tools
- JSON DiffCompare two JSON values semantically. Ignores key order; shows added, removed, and changed fields with their JSONPath — great for diffing API responses and config files.
- JSON FormatterPretty-print, minify, and validate JSON. Detects syntax errors with line numbers and supports nested structures of any depth.
- XML to JSON ConverterConvert XML to JSON for legacy API integration, SOAP responses, and config migration. Handles attributes, namespaces, and text content.
- JSON to XML ConverterConvert JSON objects and arrays to well-formed XML. Maps object keys to elements, array items to repeated elements, with optional root wrapper.
- JSON to YAML ConverterConvert JSON to clean indented YAML for Kubernetes manifests, Docker Compose, CI configs, and Helm charts. Preserves nested structures.
- JSON to CSV ConverterConvert JSON arrays to CSV with automatic header detection from object keys. Handles nested values and arbitrary delimiters.