JSON to TypeScript

Instantly convert JSON objects to TypeScript interfaces or types. Features advanced inference for unions, optional keys, and Zod schemas. Runs 100% locally in your browser.

Input

Paste JSON here

Paste your JSON directly, or load a sample.
Supports multiple JSON objects separated by ---
Output

TypeScript Output

Generated interfaces and types will appear here automatically as you type.
Configuration
Drag to resize

Why use this JSON to TypeScript Converter?

Manually writing TypeScript interfaces for complex API responses or large JSON datasets is tedious and error-prone. This tool automates the process with an advanced inference engine that goes beyond simple key-value mapping.

  • Smart Array Inference: Analyzes all items in an array to detect optional fields and union types (e.g., (string | null)[]).
  • Enum Detection: Automatically identifies string or number enums based on unique value thresholds.
  • Zod Integration: Generates ready-to-use Zod schemas for runtime validation.
  • Privacy Focused: All processing happens 100% on your device. Zero server latency, zero data leak risk.

How to convert JSON to TypeScript

  1. Paste your JSON data into the input editor on the left.
  2. Drag and drop a .json file if you prefer.
  3. The tool silently analyses your data in a background worker.
  4. Copy the generated TypeScript interfaces or Zod schemas from the right panel.
  5. Adjust options like Interface vs Type or Null Handling to customize the output.

TypeScript: Interface vs Type Alias

One of the most common questions is whether to use interface or type. Start with interfaces for defining the shape of objects, as they provide better error messages and performance in the TS compiler. Use type aliases when you need unions, intersections, or primitive aliases.

// Interface (extensible)

interface User {

id: number;

name: string;

}


// Type Alias (flexible)

type Status = "active" | "inactive";

type UserID = string | number;

Frequently Asked Questions

Is this tool free?

Yes, this tool is completely free and open for everyone. No limits on file size or usage.

Can I use this for API responses?

Absolutely. It's designed to handle complex nested JSON responses from APIs like Stripe, GitHub, or your own backend.

What if my JSON has syntax errors?

The editor will highlight syntax errors immediately. You must fix invalid JSON before the conversion can proceed.

Does it support Dates?

Yes, if "Detect Dates" is enabled, ISO 8601 date strings will be typed as Date objects in TypeScript.