CraftTools

YAML ⇄ JSON Converter

Guide: JSON vs YAML vs XML vs CSV: Choosing a Data Format

Nothing you enter or choose here leaves your device. This tool runs in your browser.

The same data in both

YAML and JSON describe the same kinds of data: objects, lists, strings, numbers, booleans and nulls. YAML uses indentation, JSON uses braces and quotes. Here is one record in each:

# YAML
name: build
on:
  push:
    branches: [main]
steps:
  - run: npm test
  - run: npm run build

// JSON
{"name":"build","on":{"push":{"branches":["main"]}},"steps":[{"run":"npm test"},{"run":"npm run build"}]}

What survives and what doesn't

FeatureYAML to JSONJSON to YAML
Values, lists, nested objectsKeptKept
CommentsLost (JSON has none)Nothing to carry
Anchors and aliasesExpanded into copiesNot created
Several documents separated by ---Becomes a list, one item per documentNot applicable
Key orderKeptKept

Gotchas worth checking

  • Words that turn into booleans. Older YAML readers treated yes, no, on and off as true and false, which is how the country code NO ended up as false. Newer ones don't, but quote such values to be safe.
  • Numbers that were meant as text. A version written as 1.10 is read as the number 1.1. Quote it: "1.10". A zip code with a leading zero, like 02134, can turn into an octal number the same way.
  • Tabs. YAML doesn't allow tabs for indentation. Use spaces, and keep the same number at each level.
  • A missing space after a colon. key:value is a single string, while key: value is a pair.
  • Long text. A pipe character keeps line breaks and a greater-than sign folds them into spaces. In JSON both become one string with escapes.

Why convert at all

  • Turn a Kubernetes or GitHub Actions file into JSON to run it through a schema checker.
  • Turn an OpenAPI description from JSON into a more readable YAML.
  • Check what a YAML file really contains after the parser has made its choices, since the JSON shows the final types.
  • Move settings between tools that each accept only one format.

If conversion fails, the message gives the line and column of the problem. YAML is read in safe mode, so a pasted file can't run code, and nothing is uploaded. Next, use the JSON formatter to tidy or validate the result, or the CSV and JSON converter for spreadsheet data. The guide to JSON, YAML, XML and CSV explains when to use which.

Converting a real file

  1. Paste the whole file, including the first line. Don't trim leading spaces, because they're part of the structure.
  2. Choose YAML to JSON and read the output. If it fails, the message gives a line and column, and the cause is usually a tab or a misaligned line one level up.
  3. Check the types in the result. A number in quotes in the JSON was text in the YAML, and an unquoted one was a number.
  4. Copy the output, or use it as the next input to go back to YAML and confirm the round trip matches.

Written by Akinrinmade Michael · Updated October 24, 2026

How to use

  1. 1Choose YAML to JSON or JSON to YAML.
  2. 2Paste your data into the input box.
  3. 3Read the converted result and pick the indentation you want.
  4. 4Click Copy output, or use the output as the next input.

Frequently asked questions

Does it keep my data exactly?

Values, lists and nested objects convert faithfully. YAML comments, anchors and formatting aren't kept, because JSON has no way to store them.

What happens with several YAML documents?

A file with documents separated by --- is converted to a JSON list with one item per document.

Is it safe to paste a config with secrets?

Conversion happens in your browser and nothing is uploaded. YAML is read in safe mode, so it can't run code.

Why is my YAML invalid?

The usual causes are tabs used for indentation, inconsistent indentation, or a missing space after a colon. The error shows the line and column to check.

Read the guide

Learn how this works and how to get the most from it.

Developer

JSON vs YAML vs XML vs CSV: Choosing a Data Format

The strengths and weaknesses of JSON, YAML, XML and CSV, with simple advice on which to use for APIs, config files and spreadsheets.

3 min read

JSON Formatter & Validator

Prettify, minify and validate JSON, with error line numbers.

JSON to DTO Generator

Turn JSON into Java, C#, TypeScript, Kotlin, Python or Go classes.

CSV ⇄ JSON Converter

Convert CSV to JSON and JSON to CSV, with any delimiter.

Text Diff Checker

Compare two texts side by side and see exactly what changed.