JSON to TypeScript Interface Generator
Convert JSON to TypeScript interfaces instantly. Paste any JSON object or array and get fully-typed TypeScript interfaces with nested types, optional fields, and readonly modifiers — all in your browser.
JSON → TypeScript Interface Generator
What does this tool do?
This tool takes a JSON object or array and generates TypeScript interface or type alias definitions. It handles nested objects (generating child interfaces), arrays, union types, and optional fields — saving you time and reducing manual type errors.
Optional fields
When optional fields mode is enabled, any property whose value is null or that appears missing in some array items will be marked with the ? optional modifier. This is useful when your JSON comes from an API that omits or nulls some fields inconsistently.
interface vs type
Both interface and type aliases work for describing object shapes in TypeScript. Interfaces are open (can be extended/merged), while type aliases support union and intersection types. Use type when you need advanced type operations; use interface for straightforward object shapes.
How to use
- Paste your JSON object or array into the input area.
- Optionally set the root interface name, toggle optional fields, and choose interface vs type.
- Click Generate TypeScript to produce the typed definitions.
- Click Copy to copy the result to your clipboard.
Your JSON stays in your browser — no data is sent to any server.
常见问题
- Can it handle nested objects?
- Yes. Nested objects generate their own named interfaces (e.g. Address, ContactInfo) and are referenced by name in the parent interface.
- What TypeScript types are generated?
- string, number, boolean, null, any[], object interfaces, and union types like string | null. Arrays of objects generate typed arrays with child interfaces.
- Does it support arrays of objects?
- Yes. Arrays of objects generate a named child interface for the item type, then type the field as ChildType[].
- Is this tool free?
- Yes, completely free with no sign-up. All processing happens in your browser — no data is sent to any server.