为什么用这个工具
03JSON YAML 转换在浏览器本地运行,适合快速处理与复制结果。
JSON YAML 转换适用于日常高频小任务,打开即用。
默认本地处理,便于快速检查与复制结果。
如何使用
02复制前快速检查
03先确认输入格式符合你的预期。
在把结果用于文档、链接、配置或消息前快速扫一眼。
只复制你真正需要的输出。
使用场景
Some Kubernetes operators emit JSON; humans usually edit YAML. Convert between them when copy-pasting examples from docs, switching between tools that prefer different formats, or generating manifests programmatically from JSON-emitting scripts.
Docker Compose YAML is human-friendly but some CI / introspection tools (especially TypeScript-typed ones) prefer JSON input. Convert your compose file once and feed both formats to different parts of your pipeline.
When a YAML config is being parsed incorrectly (wrong types, unexpected nesting, anchor expansion surprises), convert to JSON to see the exact structure your YAML parser is producing. JSON's strict typing reveals what YAML's loose typing hid.
Some configs are easier to template in JSON (or your template engine outputs JSON). Generate the JSON via your template, then convert to YAML for the final consumer.
If you suspect a config conversion is losing data, convert JSON → YAML → JSON (or vice versa) and diff against the original with our JSON Diff Checker. Differences reveal type-coercion losses (often booleans treated as strings, or vice versa).
使用技巧
- 01YAML booleans have an evil-yaml gotcha
In YAML 1.1 (which many parsers still default to), values like <code>yes</code>, <code>no</code>, <code>on</code>, <code>off</code>, <code>Y</code>, <code>N</code> are booleans. The Norway problem (country code <code>NO</code> in unquoted form becoming <code>false</code>) bit many people. YAML 1.2 fixed this but old parsers persist. If your input has such values, quote them explicitly to keep them as strings.
- 02Indentation matters in YAML, doesn't in JSON
JSON is brace-delimited so indentation is decoration. YAML uses indentation as structure — change indent and you change meaning. Convert JSON → YAML with the indent your target system expects, especially when piping into systems with strict format requirements (Helm, Ansible).
- 03Safe mode is the right default
Custom YAML tags like <code>!!js/function</code> or <code>!!js/regexp</code> allow code execution during parsing — extremely dangerous with untrusted input. Safe mode (CORE_SCHEMA) rejects these. Only disable safe mode when you control the input and have a specific reason.
- 04Anchor / alias expansion happens during YAML → JSON
YAML anchors (<code>&name</code> / <code>*name</code>) are dereferenced into copies during conversion, because JSON has no equivalent. If your YAML relies on anchor sharing (e.g., two keys both pointing to the same object), the JSON output has two independent copies. Most uses don't care, but be aware if you're processing the JSON further.
常见问题
01
这个工具会上传数据吗?
默认在浏览器本地处理。