Skip to content
AllToolsDesk

Popular

  • JSON Formatter & ValidatorFormat, minify and validate JSON with error locations.
  • CSS FormatterBeautify CSS, SCSS and Less with Prettier.
  • CSS MinifierCompress CSS and see the bytes saved.
  • JavaScript FormatterBeautify JavaScript and TypeScript.
  • JavaScript MinifierMinify JavaScript with Terser.
  • HTML FormatterIndent HTML, including inline CSS and JS.
  • JPG to PDFTurn images into a PDF, one per page.
  • Merge PDFCombine several PDFs into one file.
38 free toolsSee all tools

YAML ⇄ JSON Converter

Convert YAML to JSON and JSON back to YAML. Anchors, merge keys and multi-document files are supported, and errors show the line. Runs in your browser.

Runs in your browser. Nothing is uploaded.

Ready.

About the YAML ⇄ JSON Converter

YAML is popular for configuration because it is easy to read and write: Kubernetes manifests, Docker Compose files, CI pipelines, OpenAPI specifications and many app settings use it. JSON is stricter and is what most programs and APIs consume.

Converting YAML to JSON shows exactly how a parser will interpret your file, which helps catch indentation mistakes and surprising values. Converting JSON to YAML is a quick way to start a readable configuration from an API response or an existing JSON file. Anchors, aliases, merge keys and multi-document files are supported.

How to use the YAML ⇄ JSON Converter

  1. 1

    Paste YAML or JSON, open a .yaml, .yml or .json file, or load the sample. Pasting, opening a file or loading the sample runs it automatically.

  2. 2

    Press YAML → JSON to convert YAML, or JSON → YAML to go the other way.

  3. 3

    Choose 2 or 4 spaces of indentation for the result.

  4. 4

    Copy the result, or download it as .json or .yaml depending on the direction.

Examples

1Nested YAML to JSON
Before
name: shop
ports:
  - 80
  - 443
debug: false
After
{
  "name": "shop",
  "ports": [
    80,
    443
  ],
  "debug": false
}
2Anchors and merge keys are expanded
Before
base: &base
  retries: 3
prod:
  <<: *base
  host: example.com
After
{
  "base": {
    "retries": 3
  },
  "prod": {
    "retries": 3,
    "host": "example.com"
  }
}

Good to know

  • Comments are not carried over: JSON has no comments, so they are dropped when converting YAML to JSON.
  • Values follow YAML 1.2, so yes, no, on and off stay as text rather than becoming true or false. Dates also stay as text.
  • Files with several documents separated by --- become a JSON array, one item per document.
  • Aliases are expanded up to a fixed limit, so a file built to explode in size (a “billion laughs” file) is rejected rather than freezing the page.

Frequently asked questions

Why does my YAML report “Tabs are not allowed as indentation”?

YAML only allows spaces for indentation. Replace the tabs at the start of the reported line with spaces.

Can I convert Kubernetes or Docker Compose files?

Yes. Multi-document Kubernetes manifests become a JSON array, and Compose files with anchors and merge keys are expanded.

Is my code uploaded to a server?

No. Processing happens entirely in your browser, in a background thread. Your input is never sent to our servers or stored anywhere.

More tools that pair well with this one.

Browse all tools