JSON Tools
JSON to TypeScript
Generate TypeScript interfaces from a sample JSON value. Nested objects become named interfaces, arrays become array types, and mixed sample values become unions you can refine in your codebase.
✓ Every tool runs in your browser. We do not upload your input or output.
Keyboard shortcuts
Ctrl/⌘ + Enter: process
Ctrl/⌘ + Shift + F: full screen
Esc: exit full screen
Ctrl/⌘ + F in editor: search
How to use
- Paste representative JSON or upload a sample file. A complete object usually gives the most useful root interface.
- Read the generated interfaces and check names, optional properties, and array element types.
- Copy or download the .ts output, then rename interfaces to match your domain.
- Review and tighten types against an API schema or more samples before relying on them in production.
Examples
Type a profile response
The nested profile object receives its own interface.
{"id":42,"profile":{"name":"Avery","verified":true}}export interface Profile {
name: string;
verified: boolean;
}
export interface Root {
id: number;
profile: Profile;
}Infer an array
Array items are inspected to infer the element type.
{"tags":["admin","editor"]}tags: (string)[];
Start from an example, then refine
Sample JSON is a quick way to draft TypeScript interfaces for an API response or fixture. The generator inspects observed values: strings become string, numbers become number, booleans become boolean, nested objects receive interfaces, and arrays receive element types. This saves repetitive typing when the structure has several layers.
The output is an informed starting point, not a contract. A single sample may omit optional fields, contain null where a value is normally present, or show only one variant of a union. If an array contains objects with different keys, those missing from some items are marked optional. For a stable production type, compare several representative responses or use the API’s formal schema.
Naming and unusual keys
Generated interface names come from the parent property and may need renaming to match your project conventions. Keys that are not valid TypeScript identifiers are quoted, so the output remains valid code. The generator does not create validators or runtime checks; TypeScript types disappear at runtime. If data comes from an untrusted service, validate the response separately before treating it as one of these generated interfaces.
Frequently asked questions
Are generated types guaranteed to match an API?
No. They describe the sample you provide. Fields absent from the sample cannot be discovered.
How are mixed arrays handled?
The generator creates a union of observed item types, such as string | number, inside an array type.
Will it mark optional fields?
When objects in one sampled array have different keys, a key missing from some items becomes optional.
Can it infer literal unions or date types?
No. Strings remain string, including date-looking values. Refine the generated types using your schema and domain rules.