JSON to TypeScript Interface
Paste a sample JSON payload to generate TypeScript interfaces from it — nested objects, optional fields, and union types, detected automatically. Runs entirely in your browser; nothing you paste is ever sent anywhere.
Quick Learn
A TypeScript interface describes the shape of a value at compile time — which properties it has and what type each one is — so the compiler can catch a typo or a wrong type before your code ever runs. When you're working with an API response or a config file, writing that interface by hand means reading the payload and transcribing every field, which is slow and easy to get wrong.
This tool generates it from a real example instead: paste a sample payload and it infers a type for every field, and a named interface for every nested object. When the sample is an array of objects, it looks across every item — a field present in every item stays required, a field that only shows up sometimes becomes optional (key?: type), and a field whose type varies becomes a union (string | null). Everything runs locally in your browser.
Best Practices
- •Treat the generated interfaces as a first draft — review field names the tool had to guess a type for (empty arrays become unknown[]) and tighten them by hand once you know the real shape.
- •If your real API response can include fields your sample doesn't have, either merge a few representative samples before pasting, or widen the relevant fields manually after generating.
- •Repeated shapes (the same object structure appearing in different places) are automatically deduplicated into a single reused interface — if you see fewer interfaces than expected, that's why.
- •Property names that aren't valid TypeScript identifiers (e.g. "first-name") are automatically quoted in the output — that's expected and valid TypeScript, not a bug.
More JSON Tools
JSON Formatter & Validator
Pretty-print, minify, and validate JSON with precise error locations.
JSON Compare
Structural diff between two JSON documents.
JSON ↔ YAML Converter
Convert between JSON and YAML instantly.
JSON ↔ CSV Converter
Flatten and unflatten tabular JSON to CSV.
JSON Schema Generator
Infer a JSON Schema from a sample payload.
JSONPath Tester
Query and extract values from JSON interactively.
JSON Validator
Deep, schema-aware validation for JSON documents.
JSON to Table
View JSON as an interactive, sortable table.
Frequently Asked Questions
Want the engineering deep-dives behind tools like this one?