JSON to TypeScript
Paste JSON and instantly get matching TypeScript interface definitions with nested types and optional fields detected.
Use the JSON to TypeScript
Input JSON
TypeScript Output
Paste JSON and click Generate
Copied!
Summary
JSON to TypeScript reads a JSON value and generates the matching TypeScript interface definitions, including nested object interfaces, array element types, and union types for arrays with mixed shapes. When an array of objects is scanned, fields that are missing from some entries are marked optional so the generated types stay accurate instead of forcing every field to be required. The result is ready to paste straight into a `.ts` file.
How it works
- Paste or type JSON into the input panel, or load a sample.
- Set a root interface name (defaults to RootObject).
- Click Generate to parse the JSON and build TypeScript interfaces.
- Nested objects become their own named interfaces; arrays of objects are scanned across all items to detect optional fields.
- Review the generated interfaces in the output panel.
- Click Copy to copy the TypeScript code to your clipboard.
Use cases
- Generate types for a REST API response before writing a fetch client.
- Scaffold interfaces for a new TypeScript project from sample data.
- Check whether a JSON payload has fields that are sometimes missing.
- Document a third-party API response shape as TypeScript types.
- Speed up adding type safety to an existing JavaScript codebase.
- Turn a config file into a typed settings interface.
Frequently Asked Questions
Last updated: 2026-07-13 · Reviewed by Nham Vu