About this tool
YAML and JSON describe the same kinds of data, maps, lists, strings, numbers, booleans and null, so most documents can move between them without loss. YAML is easier for people to write and is common in configuration files such as Kubernetes manifests, GitHub Actions workflows and Docker Compose files. JSON is what most APIs and programming languages expect. This converter works in both directions using js-yaml 4.1.0, an open-source YAML parser, and runs entirely in your browser.
How to use the converter
- Pick a direction. YAML → JSON is selected by default. Choose JSON → YAML, or click Swap direction to move the current output into the input box and convert it back.
- Paste your YAML or JSON into the input box.
- Choose an indent of 2 or 4 spaces for the output.
- Click Convert. If the input has a syntax error, the status line gives the line and column, and the output box shows the offending lines.
- Copy or download the result as a
.jsonor.yamlfile.
YAML 1.2 and JSON
The YAML 1.2 specification says the main focus of version 1.2 was making YAML a strict superset of JSON. In practice that means you can paste plain JSON into the YAML → JSON direction and it will parse. The reverse is not true: comments, anchors and unquoted strings are YAML features with no JSON equivalent.
The Norway problem: is no a string or false?
YAML 1.1 defined a long list of words as booleans: y, yes, on, n, no and off in several capitalizations, alongside true and false. A list of country codes containing NO for Norway would therefore load as false, which is where the nickname comes from. The YAML 1.2 Core schema narrows booleans to true, True, TRUE, false, False and FALSE.
js-yaml 4.1.0 follows the 1.2 rule. In this tool country: no, a: yes, a: on and a: NO all come out as strings, while a: True becomes the boolean true. Going the other way, js-yaml puts quotes around strings such as 'no', 'yes', 'on' and 'y' when it writes YAML, so an older YAML 1.1 parser will still read them as text. If your YAML will be read by a tool that uses YAML 1.1 rules, quote such values yourself.
Anchors, aliases and merge keys
YAML lets you mark a node with an anchor (&name) and repeat it elsewhere with an alias (*name). JSON has no references, so each alias is expanded into a full copy of the anchored data. The YAML 1.1 merge key << is also supported: <<: *defaults copies the keys of the anchored map into the current one, and keys written explicitly next to it take priority. The anchor names themselves do not appear in the output.
Worked example
The sample in the tool uses a comment, an unquoted no, a flow-style list and a merge key. Converting it to JSON with a 2-space indent gives:
{
"service": "checkout",
"replicas": 3,
"debug": false,
"country": "no",
"ports": [
8080,
8443
],
"defaults": {
"timeout": 30,
"retries": 2
},
"staging": {
"timeout": 60,
"retries": 2
}
}
The comments are gone, country is the string "no", and staging has received retries: 2 from the anchored defaults while keeping its own timeout of 60. Click Swap direction and the JSON converts back to YAML with country: 'no' quoted, the list in block style and staging written out in full, since the anchor was not kept.
Multi-document YAML
A YAML stream can hold several documents separated by --- lines, which is common in Kubernetes manifests. When the input has more than one document, the JSON output is an array with one element per document, and the status line says how many were found. A document with nothing in it becomes null. In the JSON → YAML direction, tick the multi-document option to write each element of a top-level array as its own --- document.
What does not survive the conversion
- Comments. The spec calls comments a presentation detail that must not carry content, so parsers discard them. Converting YAML to JSON and back removes every comment.
- Dates. js-yaml reads an unquoted value such as
2026-10-07as a timestamp, and JSON has no date type, so it is written as the text"2026-10-07T00:00:00.000Z". Quote dates in YAML to keep them exactly as typed. The status line warns when this happens. - Infinity and NaN. YAML's
.infand.nanhave no JSON form and becomenull, with a warning. - Very large integers. Numbers are JavaScript doubles, so integers above 9,007,199,254,740,991 lose precision in both directions. Quote them to keep every digit.
- Key order of numeric keys. JavaScript objects list integer-like keys such as
"2"before other keys, so those keys can move to the top.
Common mistakes
- Tabs for indentation. YAML indentation must use spaces. A tab produces a parse error with the line number.
- Duplicate keys. js-yaml rejects a map with the same key twice and reports a "duplicated mapping key" error, while
JSON.parsesilently keeps the last value. - Values containing
:or starting with#. Unquoted, a second:on the line causes a parse error, and#after a space starts a comment, soa: #xloads asnull. Quote such values.
To check or pretty-print the JSON result, use the JSON Formatter, or compare two versions with JSON Diff. For tabular data, the CSV to JSON Converter may be a better starting point.
Frequently asked questions
Open the manifest, copy all of it, and paste it with YAML to JSON selected. If the file has several resources separated by --- lines, the output is a JSON array with one object per resource. kubectl can also read JSON manifests, so the converted output can be applied directly.
For practical purposes, yes. YAML 1.2 was designed as a superset of JSON, so a YAML 1.2 parser reads ordinary JSON documents as YAML. You can test this by pasting JSON into the YAML to JSON direction; the output will be the same data, reformatted.
Strings are quoted only when leaving them bare would change their meaning. Text like 123, true, null or 2026-10-07 would load as a number, boolean, null or date, and words like yes and no would be booleans for YAML 1.1 parsers, so they get single quotes. Ordinary words stay unquoted.
JSON has no comment syntax, so there are no comments to carry over. After converting, you can add YAML comments by hand with a # at the start of a line or after a value. Keep in mind they will be lost again if the YAML is converted back to JSON.
A parser reports where it noticed the problem, which can be after the real mistake. An unclosed bracket or quote, for example, is only detected when the parser reaches the end of the input. Check the reported line and the lines just above it.
Standard tags such as !!str, !!int and !!float work, so !!str 123 gives the string 123. Custom application tags such as !Ref or !GetAtt in AWS CloudFormation templates are not defined in the default schema, so the parser reports an unknown tag error. Rewrite them in their long form, such as Ref: or Fn::GetAtt:, before converting.