JSON Sample
TypeScript Interfaces
Your TypeScript interfaces will appear here.
100% Private
Type inference runs in your browser. Your JSON never leaves your device.
JSON to TypeScript infers TypeScript interfaces from a JSON sample for free. Handles nested objects, arrays, null and optional fields with recursive type inference.
Written & reviewed by Helperzy Editorial Team · Updated July 2026
JSON Sample
TypeScript Interfaces
Your TypeScript interfaces will appear here.
100% Private
Type inference runs in your browser. Your JSON never leaves your device.
Paste the richest payload you have, ideally one where every optional field is populated and arrays hold at least two elements so the merge logic can spot inconsistencies.
Give the root interface a meaningful name such as User or OrderResponse, then convert. Nested objects are named automatically from the property that holds them.
Copy the generated interfaces into your project, then narrow any over-broad types by hand — a status field inferred as string is often really a literal union.
Consuming an API in TypeScript without types means every property access is a guess the compiler cannot check. Writing the interfaces by hand from a sample response is the obvious fix and the tedious one, particularly when the payload nests four levels deep and half the fields are arrays of objects. This converter reads a JSON sample and infers the full interface set, walking every level and naming nested shapes as it goes. Anyone integrating a third-party API, typing a configuration file, or modelling a MongoDB document reaches for this rather than transcribing 60 fields by hand. The inference is a recursive walk over the parsed value, mapping each JavaScript runtime type to its TypeScript equivalent. A string becomes string, a number becomes number regardless of whether it looked like an integer, a boolean becomes boolean, and null becomes the null type rather than being skipped. An object becomes its own named interface, with the name derived from the property that held it and capitalised, so a field called billing_address produces an interface named BillingAddress referenced from the parent. Arrays are the interesting case. The tool inspects the elements, and if they are all objects it merges their key sets into one interface: a key present in every element stays required, while a key missing from any element is marked optional with a question mark. If elements disagree on a type for the same key, the result is a union like string vertical-bar number. Property names that are not valid TypeScript identifiers — anything with a dash, a space, or a leading digit — are emitted in quotes so the output compiles unchanged. A concrete run. Paste an object with an id of 42, a name of Priya Sharma, an active flag of true, a nullable deleted_at, an address object holding city and pincode, and a two-element orders array where the first item has id and total and the second has id, total, and a coupon string. Set the root name to User. You get four interfaces. User has id as number, name as string, active as boolean, deleted_at as null, address typed Address, and orders typed Order array. Address has city as string and pincode as number. Order has id as number, total as number, and coupon marked optional with a question mark, because only one of the two elements carried it. That optional marker is the part hand-written types almost always get wrong. Where it pays off. A developer wiring up a payment gateway pastes one webhook payload and gets 40 typed fields instead of reading the docs table twice. Someone migrating a JavaScript codebase to TypeScript feeds in a saved fixture from their test suite and has the response shape in seconds. A team documenting an internal service generates the interface, commits it, and treats it as the contract. A developer typing a large config file — a build tool config with nested plugin options — avoids a day of transcription. Someone modelling a Firestore document pastes an export and refines the result rather than starting from an empty file. The important limitation: inference can only describe the sample you provide. Feed it a response where an optional field happens to be absent and that field will not exist in the type at all, which produces a compile error the first time production returns it. Use the richest sample you have, ideally one with every optional field populated and at least two array elements so the merge logic has something to compare. The other thing to fix by hand is over-broad types — a status field that is really one of three values comes out as string, and narrowing it to a literal union of pending, paid, and failed is where the real safety comes from. Also remember null is not the same as optional: deleted_at typed null means it is always null, so widen it to string or null yourself. Everything runs in your browser, so real API responses containing customer data are never uploaded.
Input
{"id":42,"name":"Priya Sharma","address":{"city":"Pune","pincode":411001},"orders":[{"id":1,"total":499},{"id":2,"total":250,"coupon":"NEW10"}]} with root name User
Result
interface Address { city: string; pincode: number; } interface Order { id: number; total: number; coupon?: string; } interface User { id: number; name: string; address: Address; orders: Order[]; }
The nested address object becomes its own Address interface named from the property. The two order elements are merged: id and total appear in both so they stay required, while coupon appears in only one and is marked optional.
Input
{"deleted_at":null,"page-size":20,"tags":["new","sale"]}
Result
interface Root { deleted_at: null; "page-size": number; tags: string[]; }
A null value infers the null type, which you should widen by hand to something like string or null. The key page-size is not a valid identifier so it is quoted, and the array of strings resolves to string array.
Paste a JSON sample into the input box, optionally set a name for the root interface, and click Convert. The tool recursively infers TypeScript interfaces for the whole structure, including nested objects and arrays, and shows the result ready to copy into your project.
UUID Generator creates random UUIDs (v4) and GUIDs online for free. Generate unique identifiers instantly for databases, APIs, and development. No signup needed.
Image to Base64 Converter encodes any image into a Base64 data URI online for free. Get ready-to-use CSS and HTML code in your browser.
JSON to YAML Converter changes JSON into clean YAML instantly online for free. Validate and convert config data in your browser with no upload.
Cron Expression Generator builds and explains cron schedules online for free. Create cron expressions with a plain-English description in your browser.
Image Resizer changes image dimensions online — set exact pixels, use percentage scaling, or pick from 12 presets (Instagram, Passport, YouTube, etc.). Target specific file sizes like 50KB or 100KB. Batch resize multiple images. 100% free, browser-based.
Image Converter changes images between any format online free — JPG, PNG, WebP, AVIF, PDF, ICO, BMP, HEIC, GIF, SVG. Batch conversion, resize, rotate, flip, AI format recommendation. 100% browser-based, no upload.
Convert JPG to WebP format online free — reduce image file size by 25-35% with identical visual quality. Batch conversion, adjustable quality, lossless mode available. Boost website speed and Core Web Vitals scores. 100% browser-based, no upload needed.
Convert PNG to WebP format online free — reduce file size by 26-34% while preserving full transparency. Batch conversion, lossless and lossy modes, adjustable quality. Boost website performance and Core Web Vitals. 100% browser-based, no upload needed.