JSON → TypeScript Interface

Nested objects, unions, null handling

🔒 See this tool’s privacy notes for local processing and external service details. Site analytics are described in our privacy policy.
 

Quick guide

What can JSON to TypeScript Interface help you do?

Free online JSON to TypeScript interface converter. Handles nested objects, arrays, null, and union types. Copy and paste into your project.

Best for

Use this to draft TypeScript declarations from one JSON example and inspect nested objects, arrays, and primitive values. It infers from the supplied sample rather than an API contract, so absent fields and other possible response shapes cannot be discovered automatically.

How to use it

Paste valid JSON, keep or replace the default Root name, and choose interface or type mode. Input, name, and mode changes regenerate the output. The sample button illustrates nested declarations; resolve any JSON error before copying, and note that generated names are sanitized.

How to read the result

Null stays null, empty arrays become any[], and mixed arrays use unions. Every object gets its own declaration, sometimes with numbered names even for matching shapes. A primitive, null, or array root receives a type alias regardless of the selected declaration mode.

Privacy and limits

JSON parsing and recursive type inference happen in the browser without a remote model request or input-history storage. Declarations generally omit original values, but property names can still expose a private data model. Remove unnecessary sensitive information from real API examples before sharing them.

Sample properties are required, date strings stay string, and any[] often needs manual refinement. Empty or invalid JSON clears output and disables copying until corrected. Unusual names and generated declarations should still undergo your project type checks before being treated as usable contracts.

Frequently Asked Questions

How is null handled?

A null value is inferred as the literal null type.

Arrays with multiple types?

Auto-merged into union: (string | number)[].

Deep nesting?

Nested objects produce referenced sub-interfaces. Practical depth is limited by browser memory and the JavaScript call stack.