Boneyard Tools

JSON to TypeScript Interface Generator

Paste a JSON sample and get clean TypeScript interfaces instantly. Nested objects become their own named interfaces, arrays infer their element type, and mixed arrays become unions. Rename the root interface and copy the result.

How to convert JSON to TypeScript

  1. Paste a JSON object into the input box.
  2. Optionally rename the root interface (defaults to Root).
  3. Copy the generated interfaces or download them as a .ts file.

Examples

Flat object

{"name":"Ada","age":36,"active":true}
export interface Root {
  name: string;
  age: number;
  active: boolean;
}

Nested object and array

{"user":{"id":1},"tags":["a","b"]}
export interface User {
  id: number;
}

export interface Root {
  user: User;
  tags: string[];
}

Frequently asked questions

What does this tool do?

It reads a JSON sample and generates matching TypeScript interfaces, inferring the type of every field so you can drop the types straight into your code.

How are nested objects and arrays handled?

Each nested object becomes its own named interface, named in PascalCase from its key and de-duplicated if it clashes. Arrays infer their element type as T[], an array of objects gets a generated interface, and arrays with mixed values become a union like (number | string)[].

Are fields marked optional or required?

Every field is generated as required, since it is present in the sample. A null value is typed as null rather than made optional, so the output stays predictable. Add the optional marker yourself where a field can be missing.

What happens with keys that are not valid identifiers?

Keys like first-name or ones with spaces are quoted in the interface, for example "first-name": string, so the generated TypeScript always compiles.

Is my JSON sent to a server?

No. Parsing and type inference run entirely in your browser, so your data never leaves your machine.

Why did I get an error instead of types?

The tool needs valid JSON with an object at the top level. Invalid syntax or a top-level array, string or number returns an error message instead of interfaces.

Related tools