Developer Tools
YAML to JSON and JSON to YAML Converter
Convert YAML to JSON or JSON to YAML, with anchors, merge keys, block text and multi-document files. YAML 1.2 typing, key sorting and line-numbered errors.
How to use YAML to JSON and JSON to YAML Converter
Paste YAML or JSON; the direction is detected from the first character, or you can set it yourself. Choose 2 or 4 spaces or minified JSON, tick Sort keys if you want alphabetical order, and the converted output appears as you type.
- Paste YAML or JSONPaste a config file, a Kubernetes manifest or an API response. Input starting with {, [ or a double quote is tried as JSON first.
- Pick indent and key orderChoose 2 spaces, 4 spaces or Minified JSON (YAML to JSON only), and tick Sort keys for alphabetical keys.
- Fix errors and copyProblems such as tab indentation or duplicate keys are reported with a line number. Copy the output once it looks right.
Supported YAML features
The parser handles nested block mappings and sequences (including mappings inside list items), flow collections such as [web, api] and {k: v}, single- and double-quoted strings, | literal and > folded block text with - and + chomping, # comments, &anchors and *aliases, <<: merge keys, standard tags such as !!str and !!int, and several documents separated by ---, which become a JSON array. Tab indentation, duplicate keys, aliases without a matching anchor and inconsistent indentation are reported with the line number. Custom tags such as !Ref are ignored and only their values kept, and complex ? keys are not supported.
Type rules and round trips
Conversion follows YAML 1.2: true and false, null and ~, integers, decimals and 0x hex become JSON types, while yes, no, on and off stay strings, and numbers with a leading zero such as 01234 stay strings so postcodes and IDs keep their zeros. An unquoted version: 1.10 is a number and comes out as 1.1, so quote values that must stay text. Integers beyond ±9007199254740991 trigger a precision warning, and .inf and .nan are kept as strings. From JSON to YAML, strings that would otherwise change type, such as "true", "123" or "yes", are quoted and multi-line strings become | blocks.
Accuracy and data handling
Validate the result with your project's own tests and runtime rules before using it in production. The calculation runs in your current browser; the tool code does not send the input to a processing API.
FAQ
How are multiple YAML documents converted?
Documents separated by --- become one JSON array with one element per document, and a note tells you how many documents were found.
Why did version: 1.10 turn into 1.1?
Unquoted 1.10 is a number in YAML, and JSON writes that number as 1.1. Quote it as "1.10" in the YAML to keep it as a string.
Are comments kept?
No. JSON has no comment syntax, so comments are dropped when converting YAML to JSON, and none are created when converting JSON to YAML.
Does yes become true?
No. Under YAML 1.2 rules yes, no, on and off are ordinary strings. Only true and false (written true, True or TRUE, and likewise for false) become booleans.
More Developer Tools
Related toolsBeautify messy SQL clause by clause or squeeze it onto a single line
Pretty-print or minify XML and pinpoint errors by line and column
Convert between binary, octal, decimal, hex and bases 2–36, even for huge numbers
Turn text into ASCII codes, or decode decimal, hex and binary codes to text
Convert text to Unicode escapes for JS, Python, HTML or CSS, and decode them
Bulk-check email address syntax with reasons, typo hints and a clean list