ToolFeather
Developer / SEORuns in your browser

JSON to TypeScript Interface Generator

Paste a JSON sample and get TypeScript interfaces: nested objects become named interfaces, keys missing from some items become optional, and null values become union types.

Quick presets

JSON to TypeScript

JSON
TypeScript

Runs in your browser — nothing you enter is uploaded or stored.

ToolFeather · JSON → TypeScript
Scratchpad auto-saved
Stored in this browser (localStorage)
Step-by-step~40s read

How it works — in four simple steps

No signup and nothing to install — it all runs in your browser.

1

Add your JSON

Paste it into the left box, press Open file, or drag a .json file onto it. Sample loads a realistic example.

2

Set the options

Adjust the options above the boxes — the output updates instantly as you change them.

3

Check the result

Read the status line: it reports rows, keys and any value that couldn't be represented in TypeScript.

4

Copy or download

Copy the TypeScript or download it as a .ts file. Nothing was uploaded at any point.

Pro tip

Paste several records, not one: optional keys and null unions are inferred across all of them.

Features

Named types

Choose the root type name; nested objects become their own named types, and identical shapes are merged.

interface or type

Generate interface declarations or type aliases, optionally exported and readonly.

Private by design

Parsing and conversion run in your browser with JavaScript — your data is never uploaded, logged or stored.

About the JSON to TypeScript

Typing an API response by hand is slow and error-prone. This generator infers types from real data. It walks the JSON, and for every object it creates a named interface — the root is Root (or the name you choose), a nested address object becomes Address, and objects inside a books array become Book (singularised). Objects with exactly the same fields share one interface instead of producing duplicates.

Arrays are analysed across all their elements, which is what makes the result trustworthy: if one item has a discount key and another doesn't, the field is generated as discount?: number; if a value is sometimes null it becomes number | null; if it's sometimes a string and sometimes a number it becomes string | number. Keys that aren't valid identifiers ("first-name") are quoted. Integers and floats are both number, as in TypeScript.

Choose interfaces or type aliases, toggle export, or make every property readonly for immutable data. Paste a few representative records rather than one — more samples give more accurate optional and union types.

Examples

Two user records from an API: one has an optional field the other lacks, one value is null, and each has a nested object and a list of objects.

JSON input
[
  { "id": 1, "name": "Ada", "email": "ada@example.com", "team": { "id": 10, "name": "Core" }, "roles": [{ "id": 1, "label": "admin" }], "lastLogin": "2026-10-20T09:00:00Z" },
  { "id": 2, "name": "Alan", "email": "alan@example.com", "team": { "id": 11, "name": "Data" }, "roles": [], "lastLogin": null, "nickname": "Prof" }
]
TypeScript output
export interface User {
  id: number;
  name: string;
  email: string;
  team: Team;
  roles: Role[];
  lastLogin: string | null;
  nickname?: string;
}

export interface Team {
  id: number;
  name: string;
}

export interface Role {
  id: number;
  label: string;
}

export type UserList = User[];

This output was produced by the converter on this page with root name User — load it with the “API users” preset above and change any option to see the effect.

How JSON maps to TypeScript

In JSONBecomes in TypeScript
"name": "Ada"name: string;
"age": 36 / 36.5age: number;
Nested object addressaddress: Address; + interface Address
"tags": ["a"]tags: string[];
Key missing in some itemsdiscount?: number;
Sometimes nullnumber | null
"first-name""first-name": string;
Top-level arraytype RootList = Root[];

Things that trip people up

JSON vs TypeScript at a glance

PropertyJSONTypeScript
SpecificationRFC 8259 (2017) · ECMA-404TypeScript 5.x
File extension.json.ts
Media typeapplication/jsontext/plain
Data typesstring, number, boolean, null, object, arraystring, number, boolean, null, arrays, unions
CommentsNoYes
NestingUnlimitedNamed interfaces

Frequently asked questions

5 answers
How do I generate a TypeScript interface from JSON?
Paste JSON (ideally several sample objects) and copy the generated interfaces. Nested objects get their own named interfaces.
How does it decide a property is optional?
When analysing an array of objects, any key that is missing from at least one object is marked optional with ?.
interface or type — which should I use?
Both work for JSON shapes. Interfaces can be extended and merged; type aliases can express unions directly. Pick type alias in the options if your codebase prefers it.
Does it handle arrays of mixed objects?
Yes. All elements are merged into one interface; keys not present everywhere become optional and differing types become unions.
Is my data uploaded anywhere?
No. The JSON is parsed and converted by JavaScript in your browser tab; nothing is sent to a server, so it is safe for internal exports, customer lists and configuration files with secrets.