DEV Community

Kotaro Takaoka
Kotaro Takaoka

Posted on

Stop writing TypeScript interfaces by hand — convert JSON automatically

How many times have you received a JSON response from an API and had to manually write TypeScript interfaces for it?

I built a free tool that does it instantly: JSON to TypeScript Converter

How it works

Paste this JSON:

{
  "id": 1,
  "name": "Alice",
  "email": "alice@example.com",
  "address": {
    "street": "123 Main St",
    "city": "Springfield",
    "zip": "62701"
  },
  "orders": [
    { "id": 101, "total": 29.99, "status": "shipped" }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Get this TypeScript:

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

interface OrdersItem {
  id: number;
  total: number;
  status: string;
}

interface Root {
  id: number;
  name: string;
  email: string;
  address: Address;
  orders: OrdersItem[];
}
Enter fullscreen mode Exit fullscreen mode

It handles:

  • Nested objects (creates separate interfaces)
  • Arrays (infers element types)
  • Mixed types (string | number)
  • Null values (unknown)

Why I built this

I was building SnapAPI — a tool that creates instant REST APIs from JSON — and kept needing to convert API responses to TypeScript. So I built the converter as a standalone tool.

Other free tools

While I was at it, I built a few more:

All free, no signup, open source: github.com/ko-tarou/snapapi

Top comments (0)