JSON to TypeScript Interface
TypeScript interface
How to Use
Paste JSON on the left and the corresponding TypeScript `interface` definitions appear on the right. Nested objects each become their own interface, and array element types are inferred. The root interface name is configurable.
Type Inference Rules
Type inference uses these rules: `null` → `null`, string → `string`, number → `number`, boolean → `boolean`, array → `T[]` (or `(A | B)[]` for mixed types), object → its own interface. Array-of-objects shapes are inferred from the first element. For full type fidelity, TypeScript's own structural type system is more accurate; this tool is a starting scaffold, not a replacement.
Use Cases
- Drafting TypeScript types from a sample REST API response
- Generating types via JSON from config files or YAML
- Typing API responses when GraphQL isn't available
- Migrating JS to TS — scaffolding data type definitions from real samples
- Inferring types from sampled documents in schemaless databases (e.g., MongoDB)
Privacy
JSON parsing and type inference happen entirely in the browser. The input never leaves your device, so sensitive sample data stays local.