Handytool
สำหรับนักพัฒนาฟรีทำงานในเครื่อง

YAML formatter

Format และ validate YAML หรือ convert ระหว่าง YAML และ JSON — เป็นแบบส่วนตัวในเบราว์เซอร์ของคุณ

.yaml.yml
Indent
YAML หรือ JSON input
0 lines0 bytes
ผลลัพธ์
0 lines0 bytes

เกี่ยวกับ YAML formatter

YAML formatter ของ Handytool normalizes YAML indentation, quote style และ key order โดยใช้ standard js-yaml parser และสามารถ convert YAML ไปเป็น JSON หรือ JSON กลับไปเป็น YAML ใน one click มีประโยชน์สำหรับ cleaning up Kubernetes manifest, GitHub Actions workflow, Helm value และ any config file ที่ได้ drift จาก consistent style Parser เป็น same ที่ใช้โดย most JavaScript build tooling ดังนั้นสิ่งที่ validate ที่นี่จึงจะ validate ใน production

คุณสมบัติของ YAML formatter

  • 01

    Format และ lint

    Parse YAML ของคุณ, drop trailing whitespace, normalize indentation เป็น 2 หรือ 4 space และ re-emit มัน Syntax error ถูก surface ด้วย exact line และ reason

  • 02

    YAML ↔ JSON

    Convert YAML ไปเป็น JSON เพื่อ feed มันลงใน tool ที่ speak เฉพาะ JSON หรือ convert JSON กลับไปเป็น YAML เพื่อสร้าง config file human-friendly

  • 03

    Preserve type

    Number, boolean, null และ date round-trip correctly ผ่าน parser ดังนั้น YAML file ที่ไปเข้าเป็น YAML 1.2 ออกมา same way

คำถามที่พบบ่อยของ YAML formatter

YAML version ใดที่นี่รองรับ?
YAML 1.2 โดยค่าเริ่มต้น — version ที่ most modern tool (Kubernetes, GitHub Actions, Docker Compose) ใช้ Parser คือ js-yaml, same library ที่ใช้โดย most JavaScript build tooling
มันจะ preserve comment หรือไม่?
ไม่ Standard YAML parser ไม่ preserve comment ผ่าน parse-then-dump round trip — นั่นคือ known limitation ของ every JavaScript YAML library ไม่ใช่เฉพาะกับ tool นี้ Format file ของคุณ ก่อน add important comment กลับ
ความแตกต่างระหว่าง formatting และ converting คืออะไร?
Formatting เก็บ file เป็น YAML และเพียง normalize whitespace, key order และ indentation Converting เปลี่ยน format ทั้งหมด — YAML ไปเป็น JSON หรือ vice versa
มันจัดการ multi-document YAML หรือไม่?
Document แรกของ multi-document YAML file ถูก parse และ re-emit เพื่อทำงาน with all document split them ด้วย --- และ process each separately

เครื่องมือที่เกี่ยวข้อง

สำหรับนักพัฒนา

สำรวจเครื่องมืออื่น ๆ

เครื่องมือทั้งหมด