📄 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: >折叠块标量(换行折叠为空格)