YAML to JSON Converter (and JSON to YAML)
Convert YAML to JSON or JSON to YAML instantly, with clear errors that point to the line. Free, and it runs in your browser.
How to convert YAML to JSON
- Pick a direction, YAML → JSON or JSON → YAML, and paste your text, or load an example.
- Choose the indent. The result updates as you type; errors name the line and column.
- Copy the output or download it as a file. Use Swap to feed the output back in as the new input.
- To check the JSON is valid, or turn it into types, use the JSON Validator or JSON to TypeScript tool. Starting from a spreadsheet? Try CSV to JSON.
Worked example
This YAML:
name: CI
on:
push:
branches: [main]
steps:
- run: npm testbecomes this JSON:
{
"name": "CI",
"on": { "push": { "branches": ["main"] } },
"steps": [{ "run": "npm test" }]
}Things to know: comments are dropped (JSON has none), anchors and aliases are expanded, and unquoted values are typed by YAML's rules (8080 is a number, true a boolean, ~ null). A file with several documents separated by --- becomes an array. These are the usual steps when feeding Docker Compose, Kubernetes or CI config to a tool that only reads JSON, such as kubectl with -o json, jq or an API.
Frequently Asked Questions (FAQ)
No. Conversion runs entirely in your browser with the open-source js-yaml parser. Nothing is sent to a server, which matters when your config contains hostnames or secrets. Still, avoid pasting live credentials into any website.
Paste your YAML into the input, keep the direction on YAML → JSON, and the JSON appears instantly. Pick 2 or 4 spaces or a tab for the output, then copy or download it.
JSON has no comments, so comments are dropped. Anchors and aliases (&name and *name) are resolved: each alias is replaced with a copy of the anchored value, and merge keys (<<) are expanded. Converting back to YAML therefore will not restore the comments or anchors.
YAML guesses types from unquoted values. 8080 becomes a number, true becomes a boolean, null and ~ become null. Quote a value ("8080", "true") to keep it a string. When converting to YAML, strings that look like another type, such as "yes" or "123", are quoted automatically so they survive a round trip.
Yes. A file with several documents separated by --- (common in Kubernetes manifests) is converted to a JSON array with one element per document.
YAML uses spaces for structure and does not allow tabs for indentation. The usual causes are a tab character, items in a list not lined up, or a missing space after a colon. The error shown includes the line and column to jump to.
YAML is a superset-style, human-friendly format with comments, anchors and indentation-based structure, popular for configuration. JSON is stricter and simpler, with explicit braces and quotes, and is the standard for APIs. Most tools that read one can be given the other after conversion.
Related Tools
- Docker Run to Docker Compose ConverterPaste a docker run command and get a docker-compose.yml service: image, ports, volumes, env vars, restart, network and more. Unsupported flags are listed. Runs in your browser.
- cURL to fetch, Axios and Python requests ConverterPaste a cURL command and get JavaScript fetch, Axios or Python requests code. Parsed in your browser; nothing is uploaded.
- Cron Expression Generator and ExplainerBuild cron expressions from dropdowns, explain them in plain English and preview the next 5 run times in your timezone.
- JSON ValidatorValidate, format and visualize your JSON data with ease.
- CSV to JSON ConverterConvert CSV data to JSON format with customizable options.
- Unix Timestamp ConverterConvert epoch seconds or milliseconds to dates in UTC and local time, and dates back to timestamps. Live clock and code snippets.