JSON ↔ YAML 转换
在大小和别名限制下转换安全的 JSON/YAML 文档。
输入
提示:按 Ctrl + Enter 运行
已保存的设置
下方的详细帮助目前仅提供英文版。
关于此工具
Configuration lives in YAML (Kubernetes, GitHub Actions, Docker Compose) while APIs and many tools speak JSON. This converter translates in either direction. YAML input is parsed with a safe loader, and anchors, aliases and custom tags are refused, which blocks "billion laughs" style expansion and object-construction tricks.
Key order is preserved when converting JSON to YAML, so the result matches the original structure.
使用方法
- Paste the JSON or YAML document.
- Choose the direction: JSON to YAML, or YAML to JSON.
- Confirm server-side processing and run the conversion.
- Copy the result and validate it in the tool that will use it.
计算原理
JSON is parsed and written with yaml.safe_dump (Unicode allowed, keys not sorted). YAML is first scanned for anchor, alias and tag tokens, which are rejected, then loaded with safe_load and written as indented JSON.
计算示例
Converting {"name": "Clever Web Tools", "active": true} to YAML gives two lines, name: Clever Web Tools and active: true. Converting a YAML file that uses &defaults and *defaults anchors is refused; expand the shared values by hand first.
局限性
- Up to 50,000 characters.
- No anchors, aliases, tags or multi-document YAML.
- Comments are not preserved.
最后更新:
常见问题
Why are YAML anchors rejected?
Aliases can be abused to create documents that expand to enormous sizes, and tags can trigger unsafe object creation. Refusing them keeps conversion safe.
Will comments survive?
No. JSON has no comments, and comments in YAML are dropped during parsing.
Does YAML "yes" become true?
The safe loader follows YAML 1.1 rules, where unquoted yes/no and on/off can become booleans. Quote such values to keep them as text.
故障排除
It reports unsafe YAML.
Remove &anchor, *alias or !tag syntax and write the values out in full.
Country code NO became false.
Unquoted NO is read as a boolean in YAML 1.1. Put it in quotes: "NO".
JSON input fails.
Validate it with the JSON formatter first.
隐私 & 免费使用
我的输入会被保存吗?
此工具会将文件或输入上传到我们的隔离处理器。任务完成后会删除工作文件。请勿提交敏感或机密材料。
这个工具免费吗?
是的。无需注册或付费。