Turn YAML into JSON, anchors and multi-line strings handled.
Uses of YAML to JSON
- Converting a YAML Kubernetes manifest to JSON for a tool that expects JSON
- Turning a YAML config into JSON to validate against a JSON Schema
- Passing a YAML settings file to an API endpoint that accepts JSON
- Processing a YAML file in a language or library without YAML support
- Importing YAML data into a database or system that stores JSON
YAML to JSON pitfalls
- Indenting the YAML input with tab characters, which is invalid and fails to parse
- Expecting comments to be preserved in the JSON output
- Assuming YAML timestamps stay as dates rather than strings
- Leaving special characters unquoted, causing parse errors
YAML to JSON questions (8)
Why would I convert YAML to JSON?
JSON is the lingua franca of web APIs and most programming languages. If you have a YAML config file and need to send it to an API, validate it against a JSON Schema, store it in a database that expects JSON, or process it in a language without a YAML parser, converting to JSON first is the practical path. The conversion is lossless for the data types both formats share.
Is YAML a superset of JSON?
Yes. Since YAML 1.2, every valid JSON document is also valid YAML, which means a YAML parser can read JSON directly. The reverse is not true: YAML has features JSON lacks, such as comments, anchors and aliases, and multiple documents in one file. Those YAML-only features are resolved or dropped when converting to JSON.
What happens to YAML comments when I convert to JSON?
Comments are removed. JSON has no syntax for comments, so any lines beginning with # in your YAML are discarded during conversion. Only the data, its keys, values, and structure, is carried over into the JSON output.
How are YAML anchors and aliases handled?
Anchors (&name) and aliases (*name) let YAML reuse a block of data. When converting to JSON, the alias is expanded: the referenced data is copied in full wherever the alias appears, because JSON has no concept of references. The resulting JSON is larger but fully self-contained.
What happens to dates and timestamps in YAML?
YAML can represent native timestamps (for example, 2026-06-18). Since JSON has no date type, the converter serializes these as ISO 8601 strings so no information is lost. If you need a specific date format, quote the value in your YAML so it is treated as a plain string.
Why does my YAML fail to convert?
The most common cause is indentation: YAML uses spaces (never tabs) to define structure, and a single misaligned line changes the meaning or breaks parsing. Other causes include unquoted special characters, a missing colon after a key, or mixing tabs and spaces. The error message points to the line where parsing failed.
Can I convert the JSON back to YAML?
Yes. Use the JSON to YAML Converter, the sibling tool in this workspace. Switch direction with the pill above the editor and your result carries straight over, so you can round-trip between the two formats without copying and pasting.
Is my data private when I use this tool?
Yes. The YAML you paste is parsed and converted to JSON right in your browser, with nothing uploaded, stored, or logged on a server. You can safely convert private config files or credential-shaped data, and it works offline after the page first loads.