JSON to TypeScript Converter Online
Generate TypeScript interfaces or type aliases from any JSON sample, with nested types broken out and null handling you control.
How to Convert JSON to TypeScript
Paste a JSON payload, choose interface or type declarations, and typed definitions are generated instantly in your browser, ready to copy or download.
ステップ1
JSONを貼り付けてください
Load an API response or config sample, or use the built-in example.
ステップ2
Choose Declarations
Pick interface or type output, and set null handling, export and readonly options.
ステップ3
Copy the Types
Review the generated TypeScript, then copy it or download it as a .ts file.
Generate TypeScript Interfaces From JSON Without Hand-Writing Any Types
TypeScript types are supposed to be written once and then trusted, but the first draft usually comes from an API response pasted into a browser tab. Transcribing that payload by hand is where the mistakes live: a field typed as string when it arrives as number, a nested object left inline because splitting it out felt like too much work, an optional field marked required because the one sample you looked at happened to include it. The compiler catches none of this until the data disagrees at runtime.
This generator infers the shape from a parsed sample. Objects become interfaces or type aliases, whichever your codebase prefers, and nested objects are extracted into their own named types instead of being inlined into one unreadable declaration. Where two elements of the same array disagree, the item type merges their fields so the generated type covers every element you actually receive. Arrays of objects produce a single item type with a readable name, singularised from the key. The root type takes the name you give it, so the output drops into an existing module without renaming anything.
The options cover the conventions teams actually argue about. Null values can stay in the type union or convert the field to optional with a question mark. The export keyword can be added to every declaration. Fields can be marked readonly. Semicolons can be included or dropped to match your formatter. Array item names are singularised so a list of orders references Order rather than something unreadable.
Inference runs entirely in your browser. API responses contain tokens, customer identifiers and internal field names, and none of that is uploaded, stored or logged here. There is no account, no queue and no limit on how many payloads you can run through the generator in a session.
Copy the definitions or download them as a .ts file, drop the file into your project, and adjust the fields your application knows more about than one sample can. The output passes a formatter check as generated, which is the first thing most pipelines run before a type file is committed. The typing half of consuming an API is finished before the coffee cools.
Interface or Type
Generate interface declarations or type aliases, whichever your codebase prefers.
Nested Type Extraction
Each nested object becomes its own named type instead of an inlined anonymous one.
Null Handling
Keep null in the union or mark the field optional with a question mark.
Export and Readonly
Add the export keyword and mark every field readonly with one toggle each.
Array Item Naming
Arrays of objects get singular, readable type names derived from their key.
コピーまたはダウンロード
Take the definitions into your project as a .ts file or a clipboard paste.
よくある質問
よくある質問
Paste a JSON payload into the editor. The generator infers field types and emits interface or type declarations you can copy straight into a project without editing them by hand first.
Both describe the same shape. Interfaces extend and merge more naturally, while type aliases work with unions and mapped types, so pick whichever your codebase already uses day to day in practice.
Each nested object becomes its own named interface, and the parent references it by name, which keeps the output readable and reusable across files and modules in a project of any size.
Fields present in the sample are required. Null values can either stay in the type as null or convert the field to optional, depending on the setting you choose before generating.
All item shapes are merged into a single item interface, singularised from the key, and the field becomes an array of that item type, so the element type is named once.
Yes. Both are single toggles: export adds the keyword to every declaration, and readonly marks every field as read-only for immutability, which suits shared type files in a monorepo or a design system.
No. Strings stay strings, which keeps the output honest. Date parsing and enum inference are decisions your application should make deliberately rather than leaving them to a generator that cannot know your domain.
No. Parsing and type inference run in your browser, so API responses containing real tokens and customer data never leave your device, not even for a moment at any point during generation.
Yes. Every option is available without signup, and the generated file carries no watermark or attribution of any kind, so the types are yours to use freely in any project you like.
