JSON to Types

JSON with repeated shapes

Structurally identical objects share a single interface instead of being duplicated per key.

Input

{
  "billingAddress": { "line1": "1 Main St", "city": "Austin", "zip": "78701" },
  "shippingAddress": { "line1": "2 Oak Ave", "city": "Austin", "zip": "78702" }
}

An object with 1 nested shapes.

2 interfaces · 8 fields · 2 levels deep

TypeScript

export interface Root {
  billingAddress: BillingAddress;
  shippingAddress: BillingAddress;
}

export interface BillingAddress {
  line1: string;
  city: string;
  zip: string;
}

Zod

import { z } from 'zod';

export const BillingAddressSchema = z.object({
  line1: z.string(),
  city: z.string(),
  zip: z.string(),
});

export const RootSchema = z.object({
  billingAddress: BillingAddressSchema,
  shippingAddress: BillingAddressSchema,
});

Convert your own JSON

Paste a sample on the home page, or call the API or MCP server. This page is also available as markdown.

Related examples