Skip to content

YAML to JSON Converter

Turn YAML into strict JSON, resolving anchors, aliases and merge keys along the way.

Processed locally in your browser

Options
0 chars · 0 lines
The result will appear here.

What is YAML to JSON Converter?

YAML is a superset-like format designed for humans; JSON is what APIs and most programming languages parse natively. Converting between them is a daily task when working with Kubernetes, OpenAPI, CI files or configuration.

This converter parses your YAML 1.2 with the safe core schema, expands aliases and (optionally) merge keys, and writes JSON with the indentation you choose and optional sorted keys. If the file contains several documents separated by ---, the output is an array with one item per document. Integers larger than JavaScript can hold are written exactly, .inf and .nan become null with a warning, and custom tags are never executed.

How does it work?

  1. Paste your YAML.
  2. Choose the JSON indentation, decide whether to sort keys and whether to resolve << merge keys.
  3. Read the warnings if something could not be represented in JSON.
  4. Copy or download the JSON, or Swap to convert it back to YAML.

Common use cases

  • Feeding a YAML configuration to a tool or API that only accepts JSON.
  • Inspecting what a Kubernetes or Compose file looks like after anchors and merges are expanded.
  • Converting an OpenAPI YAML spec to JSON for a code generator.
  • Turning multi-document YAML into a JSON array.

Examples

Try this input in the tool above:

Input
defaults: &defaults
  adapter: postgres
  host: localhost
  pool: 5
development:
  <<: *defaults
  database: dev_db
test:
  <<: *defaults
  database: test_db
  pool: 1
Output
{
  "defaults": {
    "adapter": "postgres",
    "host": "localhost",
    "pool": 5
  },
  "development": {
    "adapter": "postgres",
    "host": "localhost",
    "pool": 5,
    "database": "dev_db"
  },
  "test": {
    "adapter": "postgres",
    "host": "localhost",
    "pool": 1,
    "database": "test_db"
  }
}

Privacy

YAML to JSON Converter runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.

Limitations

JSON has no comments, so they are lost. YAML features without a JSON equivalent (timestamps, binary, non-string keys) are converted to strings or Base64, and circular aliases become null.

Frequently asked questions

What happens with anchors and aliases?

They are resolved: every alias is replaced by a copy of the anchored value. The number of alias expansions is limited to stop “billion laughs” documents.

How are multiple documents handled?

A stream with several --- separated documents produces a JSON array with one element per document. A single document produces the value itself.

Are big numbers preserved?

Yes. Integers are parsed exactly and written digit for digit, so 12345678901234567890 does not become 12345678901234567000.

More tools in JSON & Data →