JSON to Types

JSON with hyphenated or reserved keys

Keys that are not valid identifiers get quoted in both outputs and need bracket access.

Input

{
  "content-type": "application/json",
  "x-request-id": "abc123",
  "class": "primary"
}

A single object shape.

1 interface · 3 fields · 1 levels deep

Where this sample is ambiguous

  • Note

    Keys that are not valid identifiers

    `content-type` and `x-request-id` cannot appear unquoted, so they are quoted in both outputs and must be accessed with bracket notation.

TypeScript

export interface Root {
  "content-type": string;
  "x-request-id": string;
  class: string;
}

Zod

import { z } from 'zod';

export const RootSchema = z.object({
  "content-type": z.string(),
  "x-request-id": z.string(),
  class: z.string(),
});

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