Developer

YAML JSON Converter

Convert YAML to JSON and JSON to YAML in your browser. Handles anchors, multi-line strings and the classic YAML type-coercion traps.

Last reviewed by the Radiatus Cloud team

Need this built for your product?

We design, build & host secure software & APIs.

Talk to an engineer

YAML is a superset of JSON

Every valid JSON document is valid YAML, which is why the conversion from JSON to YAML is always clean. The reverse is lossy in specific ways, because YAML has features JSON simply lacks: comments, anchors and aliases for reuse, multiple documents in one file, and several distinct multi-line string styles. Comments in particular are discarded silently, and in a configuration file the comments are often the most valuable part.

The Norway problem

YAML 1.1 interprets a set of unquoted scalars as booleans: yes, no, on, off, true, false and their capitalised variants. The country code for Norway is NO, so an unquoted list of country codes turns Norway into the boolean false. The same class of bug affects version numbers, where 1.10 becomes the float 1.1 and loses the trailing zero, and MAC addresses or times such as 12:30, which older parsers read as sexagesimal numbers.

The fix is always the same: quote any scalar whose type you care about. If a value must be a string, put it in quotes even when it looks obviously like one.

Indentation is the syntax

YAML uses indentation for structure and forbids tabs entirely, because tab width is ambiguous. A single stray tab produces a parse error that many editors make invisible. Configure your editor to show whitespace and to insert spaces when working with YAML.

Multi-line strings

The literal block style with | preserves newlines; the folded style with > joins lines into a paragraph. Each takes a chomping indicator: a trailing - strips the final newline and + keeps all trailing newlines. Getting this wrong is how a shell script embedded in a CI configuration ends up with its lines concatenated.

Anchors and aliases

An anchor marks a node with &name and an alias reuses it with *name, which avoids repetition in long configurations. JSON has no equivalent, so conversion expands each alias into a full copy. The output is correct but longer, and the relationship between the copies is lost.

Related tools

  • JSON Formatter — Format and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
  • JSON Validator — Validate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
  • Regex Tester — Test regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.
  • HTML Minifier — Minify HTML by removing comments and redundant whitespace, without breaking inline elements or pre blocks. Runs entirely in your browser.

Frequently Asked Questions

Why did my country code NO become false?

YAML 1.1 treats unquoted no, yes, on and off as booleans, so the code for Norway becomes false. Quote any scalar whose type matters. The same issue affects version numbers and times such as 12:30.

What happens to my comments when converting to JSON?

They are discarded, because JSON has no comment syntax. This is the main lossy part of YAML to JSON conversion and it matters most for configuration files, where comments often carry the reasoning. Keep the YAML as your source of truth.

Can I use tabs for indentation in YAML?

No. The specification forbids tabs for indentation because tab width is ambiguous. A single tab produces a parse error that most editors render invisible. Configure your editor to insert spaces and to display whitespace.

What is the difference between the pipe and the greater-than block styles?

A pipe preserves newlines exactly, which is what you want for embedded scripts. A greater-than sign folds lines into a single paragraph. Both accept chomping indicators to control trailing newlines.

What happens to anchors and aliases?

JSON has no equivalent, so each alias is expanded into a full copy of the anchored node. The data is correct but the output is longer and the shared relationship is lost, so round-tripping back to YAML will not restore the anchors.

Privacy & Security

Conversion done locally.

Data: None
Client-side-Side
Active
v1.0

About This Tool

This tool runs entirely in your browser. No data is sent to any server, ensuring complete privacy. Simply use the interface above to get started — no registration or login required.

Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.