JSON to TypeScript
Turn any JSON payload into clean TypeScript interfaces.
export interface Location {
city: string
country: string
}
export interface Profile {
title: string
location: Location
}
export interface Project {
name: string
stars: number
archived?: boolean
}
export interface Root {
id: number
name: string
isActive: boolean
roles: string[]
profile: Profile
projects: Project[]
}Why convert JSON to TypeScript?
Almost every app talks to an API that returns JSON, and every one of those responses has a shape you probably want to describe with a TypeScript interface. Writing those interfaces by hand is tedious and error-prone — miss one optional field and you get runtime surprises that types were supposed to prevent.
This converter takes a real JSON payload and generates accurate, ready-to-paste interfaces in seconds. You get compile-time safety, better editor autocompletion, and a single source of truth for the data your code depends on.
How to use it
Paste a JSON object or API response into the input on the left, optionally rename the root interface, and the TypeScript appears instantly on the right. Use Format JSON to tidy messy input, then Copy the generated types straight into your project. Everything runs in your browser, so it is safe to paste private payloads.
How types are inferred
| JSON value | TypeScript type |
|---|---|
| "hello" | string |
| 42 / 3.14 | number |
| true / false | boolean |
| null | null |
| { … } | A named, nested interface |
| [ { … } ] | A merged interface, as Item[] |
| [1, "x"] | (number | string)[] |
| missing in some rows | field?: — marked optional |
Tips for the cleanest output
Give the tool a representative sample — if a field is sometimes absent or sometimes null, include an array with both cases so the generated interface marks it optional or nullable. Rename the root interface to something meaningful (for example User or ApiResponse) and the nested interfaces will read naturally alongside it.