แปลงข้อมูลเป็นคลาส

แปลงข้อมูล JSON หรือ XML เป็นนิยาม class/struct/interface ใน TypeScript, Python, Go, Java, C#, Swift, Kotlin, Rust, Dart, JSON Schema, Ruby, C++ และอื่น ๆ นอกจากนี้: เครื่องมือ CSS | เครื่องมือ HTML | เครื่องมือ XML | เครื่องมือ YAML | เครื่องมือ JSON ทั้งหมด | ตัวตรวจ JSON Schema | ตัวดู / แก้ไข JSON | ตัวประเมิน JSONPath | JSON → SQL / TOML | ตัวจัดรูป JSON
การประมวลผลทั้งหมดเกิดขึ้นในเบราว์เซอร์ — ข้อมูลไม่ถูกอัปโหลดไปยังเซิร์ฟเวอร์ใด ๆ
อินพุต:
ภาษา:
การตั้งชื่อ:
How to use: Choose input format (JSON or XML), paste your data in the left textarea, pick a target language, and click Convert (or just type — auto-converts on input).
Batch merge: Paste multiple JSON objects (newline-separated or array) to automatically merge fields from all samples for richer type inference.
Enum detection: String fields with 2–10 distinct values are auto-detected as enums and shown in the stats panel. JSON Schema output includes enum constraints.
Naming style: Override language defaults with Auto (language convention), camelCase, PascalCase, or snake_case.
TypeScript: Generates interface definitions with proper types, optional markers (?), and array types.
Python: Generates @dataclass classes with full type hints (List, Optional).
Go: Generates struct definitions with json:"key" tags and exported field names.
Java: Generates POJOs with @JsonProperty annotations and getter/setter methods.
C#: Generates classes with [JsonPropertyName] attributes and auto-properties.
Swift: Generates Codable structs with CodingKeys enum when needed.
Kotlin: Generates data class with Jackson @JsonProperty annotations. Fields default to null. Arrays use List<T>. Nullable types use ? suffix.
Rust: Generates struct with #[derive(Debug, Clone, Serialize, Deserialize)] and #[serde(rename)] attributes. Fields in snake_case. Optional uses Option<T>. Arrays use Vec<T>.
Dart: Generates class with manual fromJson()/toJson() methods. Field names in camelCase. Nullable fields use ?. Arrays use List<T>.
JSON Schema: Generates JSON Schema (Draft 7) with $schema, definitions, and $ref references. Includes required arrays and enum constraints for detected enums.
Ruby: Generates Ruby classes with attr_accessor, initialize, self.from_json, and to_json. Field names in snake_case.
C++: Generates C++ struct with nlohmann/json to_json() and static from_json() methods. Uses std::shared_ptr, std::vector, field names in snake_case.
XML input: Parsed into JSON-like structure first. Repeated elements become arrays, nested elements become objects, empty elements become null. Attributes inferred as typed fields.
จากข้อมูลตัวอย่างไปเป็นนิยามชนิด

คลาส struct หรือ interface คือสัญญาเวลาคอมไพล์: ชื่อฟิลด์บวกชนิด การสร้างนิยามจากข้อมูลตัวอย่างเป็นการอนุมาน ไม่ใช่ความจริง — ฟิลด์ที่ไม่มีในตัวอย่างเป็นไม่ทราบ ไม่ใช่ไม่มี ค่าที่เห็นครั้งเดียวเป็น 2 จะกลายเป็นจำนวนเต็มแม้ 2.5 จะปรากฏภายหลัง รวมตัวอย่างหลายชุดเพื่ออนุมานได้ละเอียดขึ้น แล้วตรวจสอบความเป็นทางเลือกและ enum ด้วยมือ