YAML转JSON
解析 YAML 配置为标准 JSON。
关于「YAML转JSON」
它属于「JSON 工具」分类:JSON 的格式化、结构变换与各种数据格式互转。
- 支持完整的 YAML 1.2 语法:嵌套映射、序列、多行字符串、锚点引用等。
- 勾选<b>解析多文档</b>可处理用 <code>---</code> 分隔的多份文档,结果输出为数组。
- 解析出错时会给出<b>具体行号</b>,方便定位缩进或语法问题。
- YAML 里的日期、布尔值等会按标准规则转换成对应的 JSON 类型。
- 请确保缩进只用空格,含制表符的 YAML 属于非法格式。
完全免费、无需注册;所有处理都在浏览器本地完成,文件不会上传到任何服务器。
相关关键词:YAML转JSON、JSON 工具、yaml、yml、在线工具、免费
如何使用「YAML转JSON」
- 打开工具:打开「YAML转JSON」页面,无需注册、无需安装任何软件。
- 准备输入:准备好要处理的内容或文件:文本可直接粘贴,文件可拖入页面(本工具属于「JSON 工具」)。
- 填入内容:把内容粘贴进输入框,或把文件拖入页面;也可以点击「示例」先填入样例数据试一下。
- 设置选项并处理:按需调整页面上的选项,然后点击处理 / 转换 / 生成按钮。
- 获取结果:处理完全在浏览器本地完成,结果可直接复制或下载,文件不会上传到任何服务器。
常见问题
- 提示解析失败,通常是什么原因?
- 最常见的是缩进不一致,或者误用了制表符。其次是冒号后面忘记空格(应写 <code>key: value</code>),以及含特殊字符的字符串没有加引号。
- 什么是多文档 YAML?
- 一个文件里可以用 <code>---</code> 分隔多份独立文档,Kubernetes 的资源清单经常这么写。勾选对应选项后,会把它们解析成一个 JSON 数组。
- YAML 的注释会保留吗?
- 不会。JSON 格式本身不支持注释,转换后所有 <code>#</code> 注释都会被丢弃,这是格式差异导致的,无法避免。
YAML to JSON (English)
Parse YAML config into standard JSON.
Belongs to “JSON Tools”: Format, transform and convert JSON to and from various data formats.
- Full YAML 1.2 syntax: nested maps, sequences, multiline strings, anchors and more.
- Check <b>parse multi-doc</b> to handle several <code>---</code>-separated documents; output is an array.
- On error it reports the <b>exact line</b>, helping locate indentation or syntax issues.
- Dates, booleans, etc. in YAML convert to the matching JSON types by standard rules.
- Use spaces for indentation only; YAML with tabs is invalid.
Free, no sign-up; everything runs locally in your browser and files are never uploaded.
Keywords: YAML to JSON, JSON Tools, yaml, yml, online tool, free
How to use it
- Open the tool:Open the “YAML to JSON” page — no sign-up and nothing to install.
- Prepare the input:Prepare the content or file to process: paste text or drop a file onto the page (this tool belongs to “JSON Tools”).
- Provide the input:Paste your content into the input box or drop a file onto the page; you can also click “Sample” to try example data first.
- Adjust options and run:Adjust the options if needed, then click the process / convert / generate button.
- Get the result:Everything runs locally in your browser; copy or download the result — your files are never uploaded.
FAQ
- Why does it say parse failed?
- Most often inconsistent indentation or a stray tab. Next is missing space after a colon (write <code>key: value</code>), or unquoted strings with special chars.
- What is multi-document YAML?
- One file can hold several independent documents separated by <code>---</code>, common in Kubernetes manifests. With the option on, they parse into a JSON array.
- Are YAML comments kept?
- No. JSON has no comment syntax, so all <code>#</code> comments are dropped on conversion — an unavoidable format difference.
More tools in JSON Tools
- JSON Formatter/Minifier — Beautify, minify, validate and highlight JSON.
- Sort JSON Keys — Recursively sort object keys alphabetically to ease diffing.
- Flatten JSON — Flatten nested structures into a.b.c single-level keys.
- Unflatten JSON — Restore dotted-path objects into nested structures.
- JSON to CSV — Convert an array of objects into a downloadable CSV.
- CSV to JSON — Parse CSV text or files into a JSON array.
- JSON to Excel — Export an array of objects as an .xlsx workbook.
- Excel to JSON — Upload an Excel file and convert sheets to JSON.
- JSON to XML — Convert JSON structures into well-indented XML.
- XML to JSON — Parse an XML document into an equivalent JSON object.
- JSON to YAML — Convert JSON into more readable YAML.
- JSON to SQL — Generate INSERT statements and CREATE TABLE DDL from arrays.
- SQL to JSON — Reverse-engineer JSON data from INSERT statements.
- JSON to Base64 — Convert JSON to and from Base64 with UTF-8 support.
- JSON ⇄ Cookie — Convert between Cookie strings and JSON key-values.
- JSON Diff — Recursively compare two JSON documents, marking add/delete/change.