Sổ Tay AI
🦾

JSON to TypeScript Interface Generator

Convert JSON sample sang TypeScript interface chuẩn. Hỗ trợ nested object, array, optional/readonly. Dùng cho API response, LLM structured output.

Tùy chọn
TypeScript Interface
 

Chuyển JSON sample thành TypeScript interface — phù hợp cho API response, dữ liệu LLM structured output, mock data. 100% chạy trong browser.

Khi nào cần TypeScript interface từ JSON?

Tính năng

Ví dụ thực tế với Claude API

Bạn muốn Claude trả structured response. Đầu tiên thiết kế JSON sample:

{
  "summary": "Bài viết về AI",
  "topics": ["LLM", "RAG"],
  "sentiment": "positive",
  "actionItems": [
    { "task": "đọc thêm", "priority": "high" }
  ]
}

Tool sinh ra:

export interface ActionItem {
  task: string;
  priority: string;
}

export interface Root {
  summary: string;
  topics: string[];
  sentiment: string;
  actionItems: ActionItem[];
}

Dùng với Zod để validate response:

import { z } from 'zod';

const ActionItemSchema = z.object({
  task: z.string(),
  priority: z.string(),
});
const RootSchema = z.object({
  summary: z.string(),
  topics: z.array(z.string()),
  sentiment: z.string(),
  actionItems: z.array(ActionItemSchema),
});

Liên quan

Công cụ liên quan

Xem tất cả công cụ →