YAML and JSON describe the same kinds of data: maps, lists, strings, numbers, booleans and null. YAML is what people write by hand for Kubernetes manifests, Docker Compose, GitHub Actions, Ansible and OpenAPI specs; JSON is what programs, APIs and validators consume. Converting between them is routine when you check a config against a JSON Schema, send it to an API that only accepts JSON, or turn a JSON example into readable YAML for documentation.
Choose a direction, paste or open a file, and the converted text appears as you type. Swap sends the result back to the input and reverses the direction, so a round trip takes one click. The parser, js-yaml, is loaded into this page the first time you use it, and your files are never uploaded.
YAML 1.2 versus the YAML you might expect
Two YAML versions are in common use, and they disagree about unquoted values. YAML 1.1, still followed by PyYAML and many older tools, reads yes, no, on and off as booleans, 017 as an octal number, 1:30 as the base-60 number 90 and 1_000 as one thousand. That is the source of the well-known Norway problem, where the country code NO turns into false. This converter uses the YAML 1.2 core schema, in which only true and false (also written True or TRUE, and likewise for false) are booleans, so NO, yes and on stay strings, 017 is the decimal 17, and 1:30 and 1_000 stay text.
Dates are another difference. YAML 1.1 has a timestamp type, but the 1.2 core schema does not, so 2024-01-31 becomes the JSON string "2024-01-31", which is how JSON would hold a date anyway. Hexadecimal 0x1F and octal 0o17 are read as numbers, ~ and empty values become null, and .inf and .nan, which have no JSON equivalent, are written as null with a warning that counts them.
Typical conversions
Checking config with JSON tooling
JSON Schema validators, jq and many linters work on JSON. Converting a docker-compose.yml or a GitHub Actions workflow lets you query it with jq or validate it against a published schema.
Seeing what anchors and merge keys produce
YAML files often share defaults through anchors (&defaults), aliases (*defaults) and merge keys (<<: *defaults). The JSON output shows every value fully expanded, the quickest way to confirm that an override landed where you meant it to.
Writing readable config from JSON
Converting an API response to YAML gives a block-style document without braces, ready for Helm values, Ansible variables or an OpenAPI example.
How each direction works
YAML → JSON parses every document in the input. A file with several documents separated by --- lines becomes a JSON array, and a note says how many were combined. Anchors, aliases and merge keys are resolved, comments are dropped because JSON has none, and a key repeated within one mapping is reported as an error with its line and column. An alias pointing at a structure that contains it is refused, as is any document whose aliases would expand to more than a million values, the pattern behind billion laughs attacks.
JSON → YAML first checks the JSON strictly, reporting problems with line and column the same way the JSON Formatter does, then writes block-style YAML. Strings a YAML reader would take for something else are quoted, so 'yes', 'NO', '123', '2024-01-01' and 'null' keep their quotes and come back as strings. Multi-line strings use the literal | style, long lines are never folded, and empty arrays and objects are written as [] and {}. Indent sets 2 or 4 spaces in either direction.
Cómo usar esta herramienta
- Choose YAML → JSON or JSON → YAML under Direction.
- Paste your text, press Sample, or use Open file for a .yaml, .yml or .json file.
- Set the Indent to 2 spaces or 4 spaces, and read any error box or note shown under the panes.
- Press Copy or Download to save the result, or Swap to convert it back the other way.
What does not survive the trip
- Custom and extra tags are not supported. CloudFormation short forms such as !Ref and !GetAtt, GitLab's !reference, Home Assistant's !include and the !!binary and !!timestamp tags stop the conversion with an error.
- Comments, anchors and the original quoting style are lost when YAML becomes JSON; converting back gives an equivalent document, not the original text.
- Numbers are JavaScript doubles in both directions: integers above 2^53 lose precision, 1.0 becomes 1, and an unquoted version number such as 3.10 becomes 3.1.
- Keys that look like whole numbers, such as "2", move ahead of other keys because of how JavaScript orders object properties.
- Complex keys, where a list or map is used as a mapping key, are not supported, and input is limited to 10,000,000 characters.