JSON to TypeScript

Turn any JSON payload into clean TypeScript interfaces.

JSON input
TypeScript output
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 valueTypeScript type
"hello"string
42 / 3.14number
true / falseboolean
nullnull
{ … }A named, nested interface
[ { … } ]A merged interface, as Item[]
[1, "x"](number | string)[]
missing in some rowsfield?: — 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.

Frequently asked questions

How does JSON to TypeScript conversion work?+
The tool parses your JSON, walks every value, and infers a TypeScript type for it — string, number, boolean, arrays, and nested objects. Nested objects become their own named interfaces, and the result is a set of clean, reusable interface definitions.
How are optional and nullable fields handled?+
When you paste an array of objects, any key that is missing from some elements is marked optional with a question mark. Values that are null are typed as null (or unioned with their other types), so your interfaces reflect the real shape of the data.
What happens with arrays of mixed types?+
Arrays are inspected element by element. Arrays of objects are merged into a single interface, while arrays holding mixed primitives become a union type — for example a mix of numbers and strings becomes (number | string)[].
Is my JSON uploaded to a server?+
No. The entire conversion runs locally in your browser. Your JSON never leaves your device, which makes the tool safe to use with private API responses and sample payloads.
Why generate TypeScript interfaces from JSON?+
Hand-writing interfaces for large API responses is slow and error-prone. Generating them from a real payload gives you accurate types in seconds, catches shape mismatches at compile time, and improves editor autocompletion across your codebase.