JSON1

JSON → TypeScript Interfaces

Convert any valid JSON into clean TypeScript interfaces. Supports nested objects, arrays, and basic type inference.

Overview

What it does

  • • Auto-generates TypeScript interfaces from JSON.
  • • Real-time conversion while typing/pasting.
  • • Generates child interfaces for nested objects.

Input requirements

  • • JSON must be valid and parseable.
  • • Top-level array is supported but inferred from first item.
  • • Mixed-type arrays may require manual edits.

Quick Start

  1. Open /json-to-typescript
  2. Paste JSON into the left editor
  3. Review generated interfaces in the right panel
  4. Copy or download

Type Mapping

Primitives

  • • string → string
  • • number → number (no int/float distinction)
  • • boolean → boolean
  • • null → null (consider refining manually)

Complex

  • • array → T[] (inferred from first element)
  • • object → Named child interface (e.g., AddressInterface)
  • • nested object → Separate interface + field reference

Arrays & Nested Objects

Good Example

{
  "users": [{ "id": 1, "name": "A" }]
}

Needs Review

{
  "values": [1, "two", true]
}

Mixed types; adjust to a union or normalize data.

Example

Input JSON
{
  "name": "Alice",
  "age": 28,
  "active": true,
  "address": { "city": "Paris" },
  "tags": ["dev", "ts"]
}

Generated Interfaces
interface RootObject {
  name: string;
  age: number;
  active: boolean;
  address: AddressInterface;
  tags: string[];
}

interface AddressInterface {
  city: string;
}

Tips & Limitations

Recommended

  • • Validate JSON before conversion
  • • Rename interfaces to domain-specific names
  • • Add optional modifiers (?) where appropriate

Limitations

  • • Mixed arrays inferred from first element
  • • No automatic optional/union detection
  • • Complex schemas may need refinement

Read this in another language