JSON to TypeScript Interface Generator
Paste an API response or config file and get TypeScript interfaces you can drop into your project. Handles nested objects, arrays of objects, optional fields and nulls.
How to convert JSON to TypeScript
- Paste a representative JSON sample. Include several array items if fields vary between them.
- Set the root type name and choose interface or type alias.
- Copy the generated types into your project.
How the types are inferred
Each JSON object becomes an interface named after its key in PascalCase (an "address" object becomes Address). Arrays of objects are merged: a field that appears in some items but not others is marked optional with ?, and fields that are sometimes null become a union with null.
Primitive types map directly: strings, numbers, booleans and null. Arrays of mixed primitives become union arrays such as (string | number)[]. Keys that are not valid identifiers are quoted.
Generated types describe the sample, not every possible response. Review them against your API documentation, and consider stricter types for known enums (for example a status field that can only be "active" or "inactive").
Need a different tool? Suggest it here — we read every message.
Frequently asked questions
Interface or type alias?
Both work for object shapes. Interfaces can be extended and merged; type aliases can express unions. Pick your team's convention.
How are optional fields detected?
When merging array items, any field missing from at least one item becomes optional.
Is my JSON sent anywhere?
No. Conversion happens in your browser.
Does it handle empty arrays?
Empty arrays become unknown[] since there is nothing to infer from.