Skip to main content

JSON to TypeScript Interface

Paste any JSON and get TypeScript interface definitions instantly. Handles nested objects, arrays, optional fields, and custom root names. 100% client-side.

✓ 60K+ developers trust DevPlaybook ✓ Runs 100% in your browser ✓ No sign-up required

Real-World Use Cases

1. Typing a REST API Response

You call GET /api/users/42 and receive this JSON. Paste it here to get a TypeScript interface you can use with fetch or Axios.

Input JSON

{"id": 42, "name": "Alice", "email": "[email protected]", "roles": ["admin", "editor"], "address": {"city": "Taipei", "zip": "100"}}

Output TypeScript

export interface Root {
  id: number;
  name: string;
  email: string;
  roles: string[];
  address: Address;
}

export interface Address {
  city: string;
  zip: string;
}

2. Converting Stripe Webhook Payloads

Stripe webhooks send deeply nested JSON. Paste a sample checkout.session.completed event and generate type-safe interfaces for your webhook handler — no more any types.

Input (Stripe event excerpt)

{"type": "checkout.session.completed", "data": {"object": {"id": "cs_live_abc", "amount_total": 2999, "currency": "usd", "customer": "cus_xyz"}}}

Output TypeScript

export interface Root {
  type: string;
  data: Data;
}

export interface Data {
  object: SessionObject;
}

export interface SessionObject {
  id: string;
  amount_total: number;
  currency: string;
  customer: string;
}

3. Migrating a JavaScript Config to TypeScript

When moving a config.json to a typed system, paste the config JSON to generate an interface. Then use that interface to validate your config at compile time instead of runtime.

Input (config.json)

{"port": 3000, "debug": false, "db": {"host": "localhost", "port": 5432, "name": "myapp"}}

Output TypeScript

export interface Config {
  port: number;
  debug: boolean;
  db: Db;
}

export interface Db {
  host: string;
  port: number;
  name: string;
}

How to Use — Step by Step

  1. Paste your JSON — Copy a JSON response from your browser DevTools, Postman, or API docs and paste it into the input field on the left.
  2. Preview the output — TypeScript interfaces appear instantly on the right. Nested objects are split into separate named interfaces.
  3. Set the root name — Change the root interface name from Root to something meaningful like UserResponse.
  4. Toggle export — Enable the export option if you need export interface for multi-file projects.
  5. Copy & use — Click the copy button and paste the interfaces into your .ts or .d.ts file. Pair them with your API client for full type safety.

Frequently Asked Questions

How do I convert JSON to TypeScript interfaces?▼

Paste your JSON into the input field and the tool instantly generates TypeScript interface definitions. Nested objects become separate interfaces, arrays are typed by their element type, and you can customize the root interface name.

Does it handle nested JSON objects?▼

Yes. Each nested object becomes its own named interface. For example, a user object with an address sub-object generates both a User interface and an Address interface, properly referenced.

What about arrays with mixed types?▼

Arrays with elements of the same type get typed as that type (e.g. string[]). Arrays with mixed types are typed as a union (e.g. (string | number)[]). Empty arrays default to any[].

Can I add the export keyword to generated interfaces?▼

Yes. Toggle the export option and every generated interface will be prefixed with 'export'. This is useful when the interfaces will be imported across multiple files in your project.

Is my JSON data sent to any server?▼

No. All conversion runs entirely in your browser using JavaScript. Your JSON data never leaves your machine — safe for API responses containing sensitive information.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

JSON Diff Viewer JSON Diff JSON Formatter Pro JSON Path Finder YAML to JSON Converter CSV to JSON Converter JSON ↔ YAML Converter JSON Schema Form Builder Protobuf to JSON Converter CSV JSON Transformer JSON Schema to Zod Converter JSON Formatter & Validator JSON Schema Generator JSON to CSV Converter TypeScript to JavaScript Converter TypeScript tsconfig.json Generator TOML to JSON Converter SQL to TypeScript Types TypeScript Discriminated Union Builder package.json Validator & Audit TOML to JSON Converter TypeScript Playground package.json Generator Neon DB Query Builder Grafana Dashboard JSON Validator Mock Data Generator LLM JSON Schema Builder Grafana Dashboard JSON Builder Zustand Store Builder GraphQL Client Configurator Axios Interceptor Builder OpenAI Function Calling Generator Jest Mock Generator Turso Edge DB Explorer API Response Formatter & Analyzer Code Tools ESLint Config Generator JWT Builder JWT Decoder Prettier Config Generator TOML Validator YAML Validator & Formatter PWA Manifest Generator Fake Data Generator Biome Config Generator Package Lock Analyzer Feature Flag Config Generator GCP Service Account Key Checker Azure ARM Template Validator SBOM Generator JWT Debugger Pro Vitest Configuration Generator Chrome Extension Manifest Generator Jest Coverage Config Generator YAML Validator Pro API Mock Server Config Generator AWS CDK Infrastructure as Code Guide Pulumi Modern IaC Guide OpenAPI Mock Generator Drizzle Schema Generator Playwright Test Generator MCP Endpoint Tester Pulumi Stack Config Generator MCP Server Config Builder LangGraph Workflow Visualizer AWS IAM Policy Generator GCP Service Account Key Auditor TanStack Query Config Builder SWR Config Generator Jotai Atom Explorer Expo App Config Generator LLM Prompt Template Builder NFT Metadata Generator SQL JOIN Visualizer React Component Generator

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →