JSON to TypeScript
Generate TypeScript interfaces and types from JSON instantly. Merges array item shapes, detects optional properties, and names nested types.
Processed locally in your browser — nothing is uploaded.
JSON to TypeScript
0 characters
TypeScript
Output appears here…About JSON to TypeScript
Paste a JSON sample (an API response, a config file) and get TypeScript definitions for it. Nested objects become their own named types, array items are merged so properties present in only some items become optional, and keys that aren't valid identifiers are quoted.
Choose between interface and type declarations, set the root type name, and toggle export, semicolons, and readonly.
Common uses
- Type an API response you don't control
- Bootstrap types for a config format
- Get a head start on modeling third-party webhook payloads
Example
Input
{"id": 1, "name": "Ada", "tags": ["a"]}Output
export interface Root {
id: number;
name: string;
tags: string[];
}Limitations
- Types are inferred from one sample — fields that can be null or absent in other samples won't be marked unless the sample shows it
Frequently asked questions
How does the converter decide a property is optional?
By comparing objects across an array: if a key appears in some items but not others, the merged type marks it with a ? modifier. A key present in every item stays required, and you can turn this merging off.
Is my API response uploaded when I generate types from it?
No. The JSON is parsed and the TypeScript is generated entirely in your browser, so payloads containing real customer or account data never reach a server.
Why did an empty array become unknown[]?
An empty array carries no items to infer a type from, so the safest element type is unknown. Add at least one representative item to the sample and the element type will be inferred from it.
Should I generate interfaces or type aliases?
For plain object shapes they're nearly interchangeable — interfaces can be merged and extended more naturally, while type aliases also express unions. This tool emits the same structure either way, so pick whichever matches your codebase convention.
Will the generated types match every response from my API?
Only as far as your sample shows. A field that is sometimes null, absent, or a different type in other responses won't be reflected unless the sample demonstrates it, so treat the output as a starting point and adjust nullable fields by hand.