YAML/JSON Converter

YAML ⇆ JSON Converter

Convert between YAML and JSON formats. Paste your data on either side.

Ready to convert

YAML vs JSON Comparison

Feature YAML JSON
ReadabilityMore human-readableCompact, less readable
CommentsSupports comments (#)No comments allowed
Data TypesRich (dates, nulls, etc.)Limited (string, number, etc.)
IndentationSignificant (uses spaces)Not significant
QuotesOptional for stringsRequired for strings
Use CasesConfig files, K8s, DockerAPIs, data exchange

YAML Syntax Reference

Scalars

string: Hello World
number: 42
float: 3.14
boolean: true
null_value: null
date: 2024-01-15

Lists

fruits:
  - apple
  - banana
  - orange

# Inline
colors: [red, green, blue]

Objects

person:
  name: John
  age: 30
  city: NYC

# Inline
point: {x: 10, y: 20}

Multiline Strings

# Literal (preserves newlines)
message: |
  Line 1
  Line 2

# Folded (joins lines)
text: >
  This is a long
  paragraph
Horizontal Banner (Responsive) 728x90 / 320x100

How to Use This Tool

  1. Enter Your Data: Paste YAML content in the left panel or JSON in the right panel. YAML uses indentation for structure; JSON uses braces and brackets. Click "Sample" to load example data.
  2. Click Convert: Use "YAML to JSON" to convert left to right, or "JSON to YAML" for right to left. The tool parses and transforms the data structure between formats.
  3. Review the Output: The converted result appears in the opposite panel. Check for structural correctness—YAML anchors and aliases are resolved, JSON produces clean key-value pairs.
  4. Copy the Result: Click "Copy" to copy the JSON output. Use "Clear All" to reset both panels. The status indicator shows parse success or errors with details.

Technical Details

YAML (YAML Ain't Markup Language) is a human-readable data serialization format using indentation for hierarchy, colons for key-value pairs, and dashes for list items. It supports comments (#), multi-line strings (| and >), and complex features like anchors (&) and aliases (*) for references. YAML is a superset of JSON—valid JSON is valid YAML.

JSON (JavaScript Object Notation) uses explicit syntax: braces {} for objects, brackets [] for arrays, colons for key-value separation, and quotes around strings. It has no comments and strict syntax requirements. YAML to JSON conversion resolves anchors/aliases, strips comments, and adds explicit delimiters. JSON to YAML conversion removes braces/brackets and uses indentation. The data structure itself remains identical—only the serialization format changes.

Common Mistakes to Avoid

  • Indentation Errors in YAML: YAML requires consistent indentation (spaces, not tabs). Mixing 2-space and 4-space indentation, or using tabs, causes parse errors. Use a YAML-aware editor that shows whitespace characters.
  • Unquoted Special Characters: YAML values starting with *, &, !, |, >, @, or containing colons must be quoted. "key: value: more" fails; "key: 'value: more'" works. Yes/no and true/false are parsed as booleans unless quoted.
  • Losing Comments on Conversion: YAML comments (# comment) are lost when converting to JSON, which has no comment syntax. If you convert YAML to JSON and back, comments are permanently gone. Keep original YAML files as source.

Related Tools

Working with tabular data instead of configuration files? Use our CSV/JSON Converter for spreadsheet data. For validating JSON structure and syntax, try the JSON Validator.

Frequently Asked Questions

Is YAML or JSON better for configuration files?

YAML is more readable for humans (comments, no quotes on simple strings, indentation-based). JSON is better for machine-to-machine communication (stricter parsing, broader language support). Use YAML for configs humans edit, JSON for APIs and data exchange.

Why do booleans change format during conversion?

YAML accepts yes/no, on/off, true/false as boolean values. JSON uses only true/false. Converting yes to JSON produces true. Converting back produces true, not yes. The meaning is preserved; the syntax differs.

Can I preserve YAML comments when converting to JSON and back?

No—JSON has no comment syntax. Comments are permanently lost in the YAML to JSON conversion. If you need to round-trip, convert to JSON for a specific purpose, but keep the original YAML file as your source of truth.