How to use the YAML to JSON converter
- Paste YAML into the Input box. The sample is a small GitHub Actions workflow.
- Choose the Indent: 2 spaces, 4 spaces or Compact (one line).
- Copy the JSON or download it as
data.json. - If the YAML is invalid, the message gives the line and column to fix.
What it does and when to use it
YAML hides structure in indentation, so it is easy to put a key one level too deep or turn a list into a string. Converting to JSON shows the parsed result with explicit braces and brackets, which is the fastest way to debug a CI workflow, Helm values file or OpenAPI spec that “looks right” but behaves wrongly. You also need JSON when an API, a test fixture or a tool like jq will not accept YAML.
To convert back, use JSON to YAML. To tidy YAML without leaving the format, try the YAML formatter. For TOML configs there is TOML to JSON.
How it works
The tool loads the js-yaml library in your browser and reads every document in the input with YAML 1.2 core rules:
true/falsebecome booleans,null,~and empty values becomenull.- Plain digits and decimals become numbers; everything else unquoted is a string, including dates like
2024-05-01. - Anchors (
&name) and aliases (*name) are expanded. - One document gives one JSON value; several give an array.
Then JSON.stringify writes the result with your indent. Nothing is uploaded.
Worked examples
These are the tool’s own outputs.
The workflow sample. The on: key stays the string "on" rather than becoming true, and branches: [main] becomes a one-item array:
"on": {
"push": {
"branches": [
"main"
]
Values that change type. This input:
version: 1.10
country: NO
enabled: yes
port: 08080
when: 2024-05-01
empty:
zip: "02134"
gives "version": 1.1, "country": "NO", "enabled": "yes", "port": 8080, "when": "2024-05-01", "empty": null and "zip": "02134". Only the quoted ZIP code keeps its leading zero.
A merge key, compact output. With defaults: &d and <<: *d under prod, the compact JSON is {"defaults":{"retries":3},"prod":{"retries":3,"host":"db.example.com"}}. The defaults are merged into prod.
Bad indentation. key: value followed by bad: indent fails with “Invalid YAML at line 2, column 6: bad indentation of a mapping entry.”
Limits and tips
- Merge keys are applied, as shown above, so Docker Compose and CI files that rely on them come out flattened.
- Long numbers lose precision.
id: 12345678901234567890comes out as12345678901234567000; quote long IDs. - Custom tags such as
!Refin CloudFormation stop the run with “unknown scalar tag”.
Frequently asked questions
Why do yes, no and on stay as strings?
Why did 1.10 become 1.1 and 08080 become 8080?
Are anchors and aliases supported?
What happens to comments?
Can I convert a file with several documents?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.