Root name:
JSON Input 0 B
Ready
0 chars
TypeScript Output 0 B
TypeScript interfaces will appear here...
0 chars
Features

Why use this generator

Nested types

Each nested object becomes its own interface with a derived name. Array item types are inferred and unified when possible.

Type inference

Strings, numbers, booleans, null, arrays, and objects are all mapped to the correct TypeScript type. Integers and floats both map to number.

Safe identifiers

Keys that aren't valid TypeScript identifiers are wrapped in quotes. Keys starting with digits are prefixed with an underscore.

How it works

Conversion explained

1. Parse JSON

Input is parsed into a JavaScript value. The type structure is determined by walking the value tree.

2. Walk and collect

For each object encountered, a new interface is created. The interface name is derived from the parent key + field name, capitalized.

3. Emit TypeScript

Interfaces are emitted in declaration order with proper TypeScript syntax.

FAQ

JSON to TypeScript Interface Generator — frequently asked questions

How are array types inferred?

If all items in an array have the same type, that type is used with [] suffix. If types differ, a union type is created: (string | number)[].

What about optional fields?

Currently all fields are marked as required. To make a field optional, edit the output and add ? after the field name: email?: string.

Can I customize the interface names?

Yes — set the "Root name" in the toolbar. Child interface names are derived by capitalizing the field name and appending to the parent.

Does this support JSON Schema as input?

No — this tool generates TypeScript from a JSON sample. For TypeScript from JSON Schema, use a dedicated tool like json-schema-to-typescript.