Skip to main content

YAML to JSON Converter

Instantly convert YAML to JSON or JSON to YAML in your browser. Features real-time validation, syntax highlighting, configurable formatting, file upload, and 100% client-side privacy.

How to use

Paste your YAML into the Input panel and the converted JSON appears instantly in the Output panel. Click ⇄ Swap to reverse the direction and convert JSON back to YAML.

Use the Indent selector to choose 2 spaces, 4 spaces, or tabs, and toggle Minify to produce a compact single-line output. Drag and drop a .yaml, .yml, or .json file onto the input panel to load it, then click Download to save the result. All processing happens entirely in your browser — your data is never sent to a server.

YAML and JSON

YAML is the format of configuration files: Docker Compose, Kubernetes manifests, GitHub Actions and GitLab CI workflows, OpenAPI specs, Ansible playbooks. It uses indentation instead of brackets and allows comments, which makes it pleasant to write by hand.

JSON is the format of APIs and of most programming languages' data exchange. It is stricter, has no comments, and is what tools like jq, JavaScript and most HTTP clients read natively.

Both describe the same things (maps, lists, strings, numbers, booleans and null), so a document can usually be converted from one to the other without losing data.

How it works

The converter parses your input with the open-source js-yaml library and writes the result as JSON, or the other way round when you click Swap. Because JSON is valid YAML, the JSON → YAML direction accepts any JSON. You choose the indentation (2 spaces, 4 spaces or tabs) or minified single-line JSON, and you can load a .yaml, .yml or .json file by dragging it onto the input. Syntax errors are reported with the line where parsing failed.

Everything runs in your browser; files and text are never uploaded.

Example

# docker-compose.yml
services:
  web:
    image: nginx:1.27
    ports:
      - "8080:80"
    restart: unless-stopped

becomes

{
  "services": {
    "web": {
      "image": "nginx:1.27",
      "ports": [
        "8080:80"
      ],
      "restart": "unless-stopped"
    }
  }
}

The comment is gone: JSON has no comments.

Limitations

  • Comments are lost when converting YAML to JSON, and cannot come back when converting back.
  • A file with several documents (separated by ---, as in many Kubernetes manifests) is rejected with an error. Convert the documents one at a time.
  • Anchors and aliases (&default, *default) are expanded into full copies in JSON.
  • Custom tags such as !Ref or !GetAtt in AWS CloudFormation templates are not understood and cause an error.

Frequently asked questions

Why are my YAML comments missing from the JSON?

JSON has no syntax for comments, so they are dropped during conversion. Keep the YAML file as your source if the comments matter.

Why did "no", "on" or "yes" turn into true or false?

Older YAML 1.1 parsers treat yes, no, on and off as booleans. js-yaml follows YAML 1.2, where only true and false are booleans, but other tools in your pipeline may still use 1.1 rules. Quote such values ("no") to keep them as strings everywhere.

Can I convert JSON back to YAML?

Yes. Click Swap to reverse the direction. Any valid JSON is accepted, since JSON is a subset of YAML.

What does "bad indentation" mean?

YAML uses indentation to show structure, and it must use spaces, never tabs. The error points to the line where an item is indented differently from its siblings. Line items up with the others at the same level.

Does it support multiple documents separated by ---?

Not in one go: a stream of several documents is reported as an error. Split the file at each --- and convert the parts one by one.

Is my file uploaded anywhere?

No. Files you drop are read by your browser and converted locally. Nothing is sent to a server.