Skip to content

JSON إلى TypeScript

حوّل عينة JSON إلى واجهات TypeScript أو أسماء أنواع مستعارة، مع استنتاج الكائنات المتداخلة والمصفوفات والحقول الاختيارية.

بلا رفع
export interface Root {
  id: number;
  name: string;
  email: string;
  active: boolean;
  tags: string[];
  address: Address;
  orders: Order[];
}

export interface Order {
  id: string;
  total: number;
  coupon?: string;
}

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

كيفية استخدام JSON إلى TypeScript

  1. 1افتح JSON إلى TypeScript. يعمل في متصفحك دون تسجيل.
  2. 2اكتب بياناتك أو الصقها.
  3. 3انسخ النتيجة أو نزّلها.

أسئلة

How are optional fields detected?

When an array contains objects and a key is missing from some of them, that key is marked optional with ?.

What about null values?

null is kept in a union, e.g. string | null, so you can see which fields can be empty.

Is my JSON uploaded?

No — conversion happens entirely in your browser.

أدوات أخرى