JSON to TypeScript Interface Generator

Paste any JSON and get TypeScript interfaces instantly. Nested objects, arrays, and null types are all handled automatically.

Ctrl+Enter to generate

How JSON maps to TypeScript

JSON value TypeScript type
"hello"string
42 / 3.14number
true / falseboolean
nullnull
["a", "b"]string[]
[1, "x"](number | string)[]
Nested objectNamed interface

Example

JSON input:

{ "id": 1, "name": "Alice", "tags": ["admin"] }

Generated TypeScript:

interface Root {
  id: number;
  name: string;
  tags: string[];
}

Use the generated interfaces in your TypeScript project for type checking and IDE autocomplete. Paste the output directly into a .ts file.

When to Use JSON to TypeScript

Frequently Asked Questions

How does JSON to TypeScript conversion work?

The tool walks the JSON structure recursively. Each JSON object becomes a TypeScript interface. String values become string, numbers become number, booleans become boolean, null becomes null, arrays become type[], and nested objects become named interfaces derived from the key name.

How are interface names generated?

Interface names are derived from the JSON key using PascalCase conversion. The root object always becomes Root. A key named userAddress becomes UserAddress, and user_profile becomes UserProfile. Array item interfaces use the singularized key name — so a key books generates a Book interface.

Can I use the generated interfaces directly?

Yes. Copy the output and paste it into any .ts file. The interfaces are standard TypeScript and work immediately with your TypeScript compiler, VS Code IntelliSense, and other TypeScript-aware IDEs.

Is my JSON data sent to a server?

No. All TypeScript generation runs entirely in your browser using JavaScript. Your JSON data never leaves your device.

How are optional fields handled?

Fields whose value is null are typed as null (e.g. field: null). To mark a field as optional (field?: string), edit the generated interface manually — the tool infers types from the JSON you provide, so a null value does not automatically imply the field is optional in your schema.

Can I use the output with Zod or other validation libraries?

The generated output is a standard TypeScript interface, not a Zod schema. TypeScript interfaces are compile-time only and provide no runtime validation. To use Zod, translate the generated interface into a z.object() schema manually — the type mapping table above shows the equivalents.