📄 YAML to JSON Converter

📐 工作原理與說明
YAML 解析由本地 js-yaml 4.1.1 完成:完整支援引號鍵、錨點/別名、塊標量與行內註釋,複雜鍵不再被靜默丟棄;僅支援單文件,檢測到 --- 多文件時直接報錯。輸出 JSON 縮排可選 tab 或 2/4 空格;勾選排序時按鍵名字典序遞迴重排所有層級的鍵
把 YAML 轉換為 JSON。
  • 對映:YAML 的對映與序列分別轉為 JSON 物件與陣列。
  • 型別:YAML 的布林、數字與 null 會被轉為對應的 JSON 型別。
  • 錨點:YAML 的錨點(&)與別名(*)在轉換時展開為實際內容。
  • 限制:複雜鍵、多文件等 YAML 特性無法直接對映為單一 JSON,需預先處理。

YAML to JSON Converter - Paste YAML text and convert it to formatted JSON with nested maps and lists. Free, browser-only.

Formula & Standard References

Item Formula / Note Source / Standard
Mapping YAML mappings to JSON objects; sequences to arrays YAML 1.2 / RFC 8259
Anchors & anchors and * aliases must be expanded YAML 1.2
Key typing JSON keys must be strings; convert others RFC 8259
⚠️ 使用說明與注意事項

📋 常用 YAML 片段

寫法含義
key: value對映鍵值
- item列表元素
key: [a, b]行內列表
# 註釋註釋行
key: 8080 # 埠行尾註釋(解析時剝離)
desc: |塊標量(保留換行)
desc: >摺疊塊標量(換行摺疊為空格)