How to Generate TypeScript Interfaces from JSON Online
TypeScript interfaces describe the shape of your data. When you have sample JSON (e.g. from an API), you can generate interfaces automatically with a free online tool—no install, no signup.
Why Generate Interfaces from JSON?
Manually writing interface Root { ... } for large API responses is tedious and error-prone. A generator infers types from your JSON: strings, numbers, booleans, null, nested objects (as separate interfaces), and arrays. You get a starting point you can paste into your project and tweak.
Step 1: Get Sample JSON
Use a real API response, a config file, or any JSON object/array. The tool infers types from the structure. For arrays, it uses the first element to infer the item type. Validate or format your JSON first with our JSON formatter or validator if needed.
Step 2: Use the JSON to TypeScript Tool
Open our JSON to TypeScript interface generator. Paste your JSON into the input box. Click Generate TypeScript. The output shows export interface Root { ... } and any nested interfaces (e.g. User, Item0). All processing runs in your browser.
Step 3: Copy or Download
Copy the output into a .ts file in your project, or use Download .ts to save types.ts. You can rename interfaces, add optional modifiers, or union types as needed.
What Gets Generated?
Primitives become string, number, boolean, null. Nested objects become separate interfaces (names from keys when possible, e.g. user → User). Arrays of objects become InterfaceName[]. Empty arrays become unknown[].
Summary
Paste JSON into the JSON to TypeScript generator, click Generate, then copy or download the interfaces. Use it for API types, config types, or quick scaffolding. For more JSON tools see our formatter, JSON to CSV, and developer tools.