JSON to TypeScript Converter

Generate TypeScript interfaces and types from JSON data instantly. Handles nested objects, arrays, nulls, and complex structures.

Left Panel

JSON Input

Right Panel

TypeScript Output

How to Use

  1. Paste your JSON data or click “Sample” to load example data.
  2. Configure options: root name, interface vs type, readonly, export, optional nulls.
  3. TypeScript interfaces are generated instantly in the right panel.
  4. Copy to clipboard or download as a .ts file.

Features

Nested Object Support

Nested JSON objects are extracted into separate named interfaces with proper references.

Array Type Inference

Arrays are typed based on their contents. Mixed-type arrays produce union types automatically.

Interface vs Type

Choose between TypeScript interfaces (declaration merging) or type aliases.

Readonly & Optional

Mark all properties as readonly, and automatically make nullable fields optional.

Related Tools

Related Guides

Frequently Asked Questions

How does JSON to TypeScript conversion work?

The tool parses your JSON, infers TypeScript types from the values (strings → string, numbers → number, objects → interfaces, arrays → typed arrays), and generates clean TypeScript interfaces or type aliases. Nested objects become separate named interfaces.

Does it handle arrays with mixed types?

Yes. When array items have different shapes (e.g., some objects have extra fields), the tool creates union types or optional properties to represent all possible item structures accurately.

Should I use "interface" or "type"?

Interfaces are preferred for object shapes because they support declaration merging and are more readable. Types are useful when you need union types, mapped types, or conditional types. The default is interface.

What does "optional nulls" do?

When enabled, any property whose value is null in the JSON will be marked as optional (?) in TypeScript. This is the most common pattern since null usually means "this field may not be present."

Can I customize the root type name?

Yes. Enter any PascalCase name in the "Root name" input. Nested types are automatically derived from property names (e.g., an "address" property generates an "Address" interface).

Is my data uploaded to a server?

No. All conversion happens entirely in your browser. Your JSON data never leaves your machine.