JSON → TypeScript Interface
Paste a JSON sample (an API response, a config, a fixture) and get back a ready-to-paste TypeScript interface. Nested objects become their own interfaces named after the parent key (in PascalCase), arrays infer the element type, and primitives stay primitives. Merge mode walks every element of an array to produce a union; first-only mode infers from element zero (faster for huge arrays).
export interface Post {
id: number;
title: string;
tags: string[];
}
export interface Address {
city: string;
zip: string;
}
export interface Root {
id: number;
name: string;
active: boolean;
joinedAt: string;
roles: string[];
address: Address;
posts: Post[];
}How to use
- Paste a JSON sample.
- Set a root type name and choose interface or type-alias style.
- Pick array handling — merge (safer) or first (faster).
- Copy the generated TypeScript.
Frequently asked questions
- Why does my array of users produce a User interface?
- Keys that look plural (users, posts, tags) are singularized for the nested type name. So 'posts': [...] generates a Post interface, used as Post[].
- What does merge vs first do?
- Merge walks every array item and unions the field types, so 'optional' fields that are missing in some items become 'field?'. First only looks at item zero — fast but misses union types and optionality.
- Are dates inferred as Date?
- No — TypeScript can't tell a date string from any other string at compile time. The tool keeps them as 'string' so the output is correct in strict mode.
- What about null?
- null becomes its own type. If a field is sometimes null in merge mode, you get 'field: string | null' instead of 'field: string'.
Related tools
JSON Schema Generator
Paste any JSON and get a draft-07 JSON Schema that matches its shape — types inferred, formats detected, required fields filled in.
JSON to Zod Schema Generator
Turn a JSON object into a Zod validation schema with inferred types, in your browser.
JSON to GraphQL Schema (SDL) Converter
Turn a JSON object into GraphQL type definitions (SDL) with scalar mapping, in your browser.
Mock Data Generator
Generate realistic fake records for testing — names, emails, dates, IDs, lorem — exported as JSON, CSV, or SQL INSERTs.
JSON to JSDoc @typedef Generator
Turn a JSON object into JSDoc @typedef blocks with @property tags, in your browser.
JSON to Python Dataclass Converter
Turn a JSON object into Python @dataclass definitions with type hints, in your browser.