Tool
JSON to TypeScript interfaces
Paste JSON samples and get TypeScript interfaces locally: deduplicated nested shapes, optional and null unions, field overrides, .ts download.
1. JSON samples
Input stays in this tab: a local worker infers the structure, with no upload, URL fetching, storage or API calls.
Inferred from samples, not a complete API contract. Add varied real samples, review missing fields, null and empty arrays, then confirm the output with the API owner.
2. Inferred output
Primitive and array roots use a type alias even in interface mode; object structures become named interfaces. Schema properties remain open to additional fields.
Inference notes
Review field types and optionality
Paths use JSON Pointer escaping; /* means array elements. A type override replaces that entire field, including a nested object. Selecting “inferred” restores its inferred structure. Repeat-shape types are deduplicated again after every edit. Child field edits have no effect while their parent is overridden.
| Path | Inferred / current type | Override type | Optional |
|---|
Limits and interpretation
A field missing from some object samples becomes optional; explicit null stays null or forms a union. Empty arrays infer unknown[] until non-empty array samples provide evidence. Mixed values form unions; repeated object shapes share a named type. First-seen field order and two-space indentation are stable. Numbers infer number, never enums or date formats.
Limits: 500,000 characters, 20,000 JSON values, 500 inferred fields and 64 nesting levels. Duplicate keys and unsafe numeric integers are rejected with source positions to avoid silently losing evidence. This tool does not generate OpenAPI documents, fetch URLs, validate live backend responses or infer future fields from a single example.
FAQ
Interface or type alias — which do I get?
Object roots become named interfaces; nested repeated shapes are deduplicated into their own interfaces. Primitive and array roots use a type alias. Switch the output to the type format if you prefer aliases for objects too.
How are optional fields decided?
In the object-samples mode, a key missing from some sample objects becomes optional (a ? marker). In single-value mode every present key is required. Missing keys are the main thing to verify with real API responses.
What do null and mixed values become?
Explicit null stays in the union (string | null). Mixed types form unions; empty arrays infer unknown[] until a sample with elements exists. Override any field in the field table if inference guesses wrong.
Are keys quoted safely?
Keys that are not valid TypeScript identifiers are emitted with quotes, so JSON like hello-world still produces valid code. Numbers infer number — enums and date strings are not guessed.
Is my JSON uploaded?
No. A local worker parses and infers in this tab. Nothing is sent to a server, stored, or fetched from a URL.