Skip to content
DayUtils

YAML to JSON Converter – and JSON to YAML

Convert YAML configuration files to JSON, or JSON back to clean, readable YAML. Works with Docker Compose, Kubernetes manifests, GitHub Actions workflows, OpenAPI specs and any other YAML, with clear error messages when the input isn’t valid.

Loading tool…

How to use the YAML to JSON converter

  1. Choose YAML → JSON or JSON → YAML.
  2. Paste your YAML or JSON, or press Try an example.
  3. Choose 2 or 4 spaces of indent.
  4. Copy the result or Download it.

YAML and JSON side by side

name: my-app
version: 1.2.0
features:
  - search
  - dark-mode
server:
  port: 8080
  debug: false

converts to

{
  "name": "my-app",
  "version": "1.2.0",
  "features": ["search", "dark-mode"],
  "server": { "port": 8080, "debug": false }
}

Note that 1.2.0 stays a string (it isn’t a valid number), while 8080 and false become a number and a boolean.

YAML syntax essentials

  • Key–value pairs: key: value, with a space after the colon.
  • Nesting: indent child keys with spaces — never tabs.
  • Lists: each item starts with - .
  • Strings: usually unquoted; quote them if they contain :, # or look like numbers or booleans.
  • Multi-line text: | keeps line breaks, > folds them into spaces.
  • Comments: start with #.
  • Multiple documents in one file are separated by ---.

Common uses

  • DevOps: converting Kubernetes manifests, Helm values and Docker Compose files.
  • CI/CD: checking GitHub Actions and GitLab CI workflows.
  • APIs: switching OpenAPI and Swagger specifications between formats.
  • Apps: turning a YAML config into JSON for a tool that only reads JSON.

Why teams use both formats

YAML is easier for people to write and review, so it is common for hand-edited configuration. JSON is stricter and universal, so it is common for data exchanged between programs. Many tools accept both: Kubernetes, OpenAPI and ESLint, for example. Converting lets you write in whichever format you prefer and still feed a tool that needs the other one. When reviewing changes, YAML diffs are often easier to read because each value sits on its own line without brackets and commas.

Strings and special characters

Values such as yes, null, 1e3 or 08:30 can be read as booleans, null, numbers or times by some parsers. When a value must stay text, wrap it in quotes.

Indentation errors

Most YAML errors come down to indentation. Every item at the same level must start in exactly the same column, and child items must be indented further than their parent. Many editors can show whitespace characters, which makes stray tabs easy to spot. If you copy YAML from a web page, re-check the indentation, because some pages replace spaces with non-breaking spaces that YAML parsers reject.

Tips

  • Validate before deploying: a converted JSON file that looks wrong usually means the YAML indentation is off.
  • Quote version numbers and IDs such as "1.10" so they aren’t read as numbers (1.10 would become 1.1).
  • Watch anchors and aliases (& and *): they are expanded in the JSON output.

Format JSON with the JSON formatter, or convert spreadsheets with CSV to JSON.

Frequently asked questions

What is YAML?

YAML (“YAML Ain’t Markup Language”) is a human-friendly data format that uses indentation instead of brackets. It is popular for configuration files because it is easy to read and supports comments.

Is all JSON valid YAML?

Almost. YAML 1.2 is designed as a superset of JSON, so most JSON documents are also valid YAML. Converting from JSON to YAML mainly makes the file easier to read.

Are comments kept?

No. JSON has no comments, so YAML comments are lost when converting to JSON, and JSON can’t provide comments when converting back.

Why does my YAML give an error?

The most common causes are tabs used for indentation (YAML requires spaces), inconsistent indentation, a missing space after a colon, and unquoted values that contain special characters like : or #.

Why did “no” become false?

Older YAML 1.1 parsers treat yes, no, on and off as booleans. This converter follows YAML 1.2, where only true and false are booleans, but quote such values to be safe in other tools.

Is my file uploaded?

No. Conversion runs in your browser, so configuration containing internal hostnames or settings stays private.

Last updated: