Bytelify

JSON to TypeScript

Infer TypeScript interfaces from a sample JSON value, live as you type.

Runs in your browser, nothing sent
json-to-typescript
TypeScript interfaces
interface Root {
  id: number;
  name: string;
  active: boolean;
  tags: string[];
}

Infers TypeScript interfaces from a sample JSON value, live as you type โ€” one interface per nested object shape. Since it only sees one sample, it can't know if a field is ever optional or a union of types; review the output before using it. Runs entirely in your browser.

Need the opposite? JSON to XML Converter

What is JSON to TypeScript?

Paste a sample JSON value (an API response, a config object) and get inferred TypeScript interfaces instantly, one interface per nested object shape, saving the tedium of hand-writing types for a large response. A fast starting point when integrating a new API: paste one real response and get a typed shape to work against immediately, instead of hand-writing an interface field by field. Inference happens live in your browser as you type.

How to Use JSON to TypeScript

  1. 1

    Paste a Sample JSON Value: Enter a real API response or config object.

  2. 2

    Read the Inferred Interfaces Instantly: TypeScript interfaces appear automatically, one per nested object shape.

  3. 3

    Copy and Refine: Copy the result into your codebase and adjust for optionality or unions your API may actually have.

How the Mapping Works

Each JSON object's keys become interface properties, and each value's JSON type is mapped to its TypeScript equivalent: a string stays string, a number stays number, a boolean stays boolean, and null becomes null. A nested object gets its own named interface, referenced by the parent property's type, rather than being inlined.

Example

JSON
Input:
{ "id": 1, "name": "Alice", "active": true, "address": { "city": "Boston" } }

Output:
interface Address {
  city: string;
}

interface Root {
  id: number;
  name: string;
  active: boolean;
  address: Address;
}

The nested "address" object gets its own Address interface, referenced from the root interface's address property.
FAQs

Frequently Asked Questions

Common questions about JSON to TypeScript.

They're inferred from one sample, so a field that's sometimes null, sometimes a different type, or sometimes absent won't be reflected. Review the output and adjust for optionality/unions your API actually has.

From the shape of their items. An array of objects produces an interface for that object shape plus an array type referencing it; an array of primitives produces a simple primitive array type.

An empty array has no items to infer a shape from, so it typically falls back to a generic type like any[] or unknown[]; a null value is typed as null, which you may want to widen into an optional or union type by hand.

It generates interface declarations, one per distinct nested object shape, which is the more common convention for describing object shapes from sample data.

Yes, Bytelify's JSON to TypeScript tool is free with no account or sign-up required.

No. The inference runs entirely client-side in your browser, so nothing you paste is sent anywhere.