Conservatively convert JSON to TypeScript interfaces or types with safe optional fields, unions, and unknowns.
JSON input
TypeScript types
JSON is processed only in this browser and is never uploaded. Press ⌘/Ctrl + Enter to generate.
Conservative TypeScript inference from JSON
Strictly validate JSON, recursively generate interface or type declarations, and merge multiple object samples in arrays. Missing fields become optional, observed type conflicts become explicit unions, and unsafe property names are quoted correctly.
The inference policy never guesses when the evidence is incomplete. Date-looking values remainstring; empty arrays, empty objects, and null-only fields use unknown with a visible warning. Duplicate keys, invalid JSON, and structures beyond the safety limits stop conversion without returning an ambiguous result.
How to use
Paste JSON, including multiple real object samples in an array when available;
Choose a root type name and select interface or type;
Review conservative-inference warnings and refine any unknown types for your domain;
Copy the result or download it as a TypeScript file.
FAQ
Why does an empty array become unknown[]?
An empty array provides no evidence that its elements should be strings, objects, or another type. unknown[] explicitly represents that uncertainty instead of inventing a concrete type.
Does the tool convert date-looking strings to Date?
No. Dates are still strings in JSON, and formatting alone cannot establish business semantics. The conservative default is string, avoiding false Date inference.
How are optional properties in object arrays inferred?
All object samples in the array are merged. A field missing from any sample becomes optional, while fields observed with different types receive an explicit union type.
Is my JSON uploaded?
No. JSON validation, structural inference, and TypeScript generation all run locally in your browser, so the input never leaves your device.