YAML to JSON converter

What is a Yaml To Json Converter?

YAML is the configuration language of Kubernetes, Docker Compose, GitHub Actions, GitLab CI and Ansible. Under the hood, YAML is a superset of JSON, and many tools convert it to JSON before using it. Converting YAML to JSON shows you exactly how a parser interprets your file, which is the quickest way to debug indentation and type problems.

How to use it

  1. Paste YAML.
  2. Read the JSON output, which updates live, and any parse errors.

Example

Input:

defaults: &defaults
  retries: 3
  timeout: 30s
service:
  <<: *defaults
  name: api
  ports: [80, 443]
  description: |
    Public API
    behind the load balancer

Output (with single quotes here):

{ 'defaults': { 'retries': 3, 'timeout': '30s' },
  'service': { 'retries': 3, 'timeout': '30s', 'name': 'api',
    'ports': [80, 443], 'description': 'Public API\nbehind the load balancer\n' } }

The anchor &defaults and merge key <<: *defaults are expanded, and the block scalar | keeps line breaks.

YAML gotchas the JSON reveals

  • The Norway problem: in YAML 1.1 parsers, unquoted NO, yes, on and off become booleans. Quote country codes and flags.
  • Version numbers: version: 1.10 becomes the number 1.1. Quote it.
  • Leading zeros: zip: 01234 may be read as an octal or plain number.
  • Indentation: a list item indented one space too few moves to a different parent.
  • Tabs are not allowed for indentation.

Frequently Asked Questions

Is YAML a superset of JSON?

YAML 1.2 is designed as a superset of JSON, so most JSON documents are also valid YAML.

Why did my value no become false?

YAML 1.1 parsers treat unquoted yes, no, on and off as booleans. Quote the value to keep it as a string.

Are YAML anchors and aliases supported?

Yes. Anchors, aliases and merge keys are expanded into full values in the JSON output.

Why does my YAML fail to parse?

Usually because of inconsistent indentation, tab characters or a missing space after a colon.