More
More
YAML to JSON Converter
Paste YAML, such as a Kubernetes manifest or a CI config, and get the same data as formatted JSON.
Free tools that run in your browser. Nothing you type, open or create is uploaded to NerdBible or anyone else.
Converted in your browser with js-yaml (MIT licence). YAML comments, anchors and custom tags have no JSON equivalent, so comments are dropped and anchors are written out in full. A YAML file with several documents separated by --- becomes a JSON array.
The rules: a key starting with @ is an attribute, the key #text holds an element's text next to attributes or children, and an array becomes the same element repeated. When there is more than one top-level key, the XML is wrapped in a root element. Comments, processing instructions and the DOCTYPE are skipped when reading XML, and entities other than the five standard ones are not expanded.
Nested objects are flattened into dot keys (address.zip) and arrays into numbered keys (tags.0, tags.1), and the reverse when converting back. Columns appear in the order they are first seen. CSV follows RFC 4180: fields with the delimiter, a quote or a line break are wrapped in double quotes. TSV is the same with a tab between fields.
TOON (Token-Oriented Object Notation) is a compact way to write JSON for large language model prompts: objects use indentation instead of braces, and a list of objects that share the same keys is written once as a header, such as hikes[3]{id,name,km,sunny}:, followed by one row per item. This converter follows the public TOON specification for objects, inline lists, tabular arrays, list items, quoting and the comma, tab and pipe delimiters.
How to use it
- Pick the format: YAML, XML, CSV, TSV or TOON. Then pick the direction, such as JSON to YAML or TOON to JSON.
- Paste your data. The result updates as you type, and an error shows its line and column.
- Set the options: indent and key order for YAML, the declaration and value types for XML, the delimiter, header row and quoting for CSV and TSV, or the delimiter and indent for TOON.
- Copy or download the result, or press Swap to convert it back.
Questions
Why does my YAML fail to convert?
The most common causes are tabs used for indentation, inconsistent indentation and a missing space after a colon. The error message gives the line and column to look at.
What happens to YAML comments?
They are removed, because JSON has no way to store comments.
Will yes and no become true and false?
No. The converter follows the YAML 1.2 core schema, where only true and false are booleans. Yes, no, on and off stay as strings.
About this tool
What the conversion does
YAML and JSON describe the same kinds of data: maps, lists, strings, numbers and booleans. The converter parses your YAML with js-yaml and writes the result as JSON with the indent you choose.
- Errors point to the line. A tab used for indenting or a missing colon is reported with its line and column, so the converter doubles as a YAML validator.
- Comments are dropped. JSON has no comments, so anything after a # disappears.
- Anchors and aliases are expanded. A block reused with & and * is written out in full wherever it appears.
- Several documents separated by --- become a JSON array with one item per document.
Watch the types
Values are read with the YAML 1.2 core rules: true and false are booleans, while yes, no, on and off stay as text. That avoids the classic surprise where the country code NO turned into false. Quote a value in the YAML when it must stay a string, such as a version number like 1.10.
Sort keys A to Z helps when comparing two files. Nothing is uploaded.
Related tools
- JSON Formatter & ValidatorPretty-print, minify and validate JSON.
- Code Formatter & MinifierFormat or minify HTML, CSS, JavaScript, SQL, XML, YAML and GraphQL, and check XML.
- Diff CheckerSee what changed between two texts or two JSON files.
- JSON to TypeScriptTypeScript types from a JSON sample.