JSON → TypeScript Interface
Developer
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
JWT Decoder
Decode a JSON Web Token to inspect its header, claims, and expiration.
UUID Generator
Generate random version-4 UUIDs in bulk, with copy.
Hash Generator (SHA)
Generate SHA-1, SHA-256, SHA-384, and SHA-512 hashes from text.
URL Encoder / Decoder
Percent-encode text for URLs, or decode encoded URLs back to text.
Base64 Encoder / Decoder
Encode text to Base64 or decode Base64 back to text, instantly.
JSON Formatter & Validator
Format, beautify, minify, and validate JSON right in your browser.