Skip to content

YAML to JSON Converter

Convert YAML, including lists, block strings and anchors, into JSON, or convert JSON objects and arrays into clean, correctly quoted YAML.

Runs in your browser Free, no sign-up
Loading tool workspace...

What is YAML to JSON Converter?

This YAML to JSON converter translates configuration between the two formats. YAML is the human-friendly format of Kubernetes, Docker Compose, CI pipelines, OpenAPI (Swagger) specs and many app settings; JSON is what most APIs, JavaScript code and validators expect. YAML to JSON parses the whole file, including nested mappings, lists, multi-line strings and anchors, and produces the equivalent JSON with numbers, true, false and null typed correctly.

JSON to YAML goes the other way: objects become indented mappings, arrays become - item lists, and strings that YAML could misread are quoted automatically. Converting is handy when a tool accepts only one of the formats, or when you want to check exactly how a YAML file's indentation is being interpreted.

How to use YAML to JSON Converter

  1. Choose YAML → JSON or JSON → YAML.
  2. Paste your YAML or JSON into the input panel.
  3. Read the converted output; if the YAML is invalid, the error and its line number are shown instead.
  4. Copy or download the result.

Key features

  • YAML to JSON and JSON to YAML
  • Full YAML 1.2 parsing: lists, block strings, anchors and multiple documents
  • Numbers, booleans and null typed correctly
  • Automatic quoting of strings YAML could misread
  • Error messages with line numbers for invalid YAML
  • Runs in your browser; secrets in configs stay private

Common use cases

  • Converting JSON settings into YAML for Kubernetes, Compose or CI files
  • Turning YAML configuration into JSON for APIs and validators
  • Checking how nested YAML mappings are interpreted
  • Moving app configuration between frameworks that use different formats
  • Generating YAML from JSON produced by scripts

Technical details & standards

YAML to JSON uses a full YAML 1.2 parser: block and flow mappings and lists, plain and quoted strings, literal (|) and folded (>) block scalars, comments, anchors and aliases, merge keys (<<) and tags are all supported. Values are typed with the YAML 1.2 core schema, so 42 and 3.14 become numbers, true, false and null become JSON literals, and yes, no and dates stay strings. A file with several documents separated by --- becomes a JSON array with one element per document.

JSON to YAML writes objects as mappings and arrays as - item lists with 2 spaces per level, including arrays of objects. Strings that YAML would read as another type, such as "yes", "null", "1.0" or values containing ": " or " #", are quoted, and multi-line strings become literal (|) blocks, so the YAML parses back to exactly the same data.

Frequently asked questions

Is YAML a superset of JSON?

Mostly: YAML 1.2 is designed so that any valid JSON document is also valid YAML. That is why converting JSON to YAML is lossless, while YAML features such as comments and anchors have no JSON equivalent.

Does the converter support YAML lists?

Yes. Lists become JSON arrays, including lists of objects such as Kubernetes containers or CI steps, and JSON arrays become - item lists when converting the other way.

Why did yes stay a string?

This converter follows YAML 1.2, where only true and false are booleans, so yes, no, on and off are strings. YAML 1.1 parsers, such as older PyYAML versions, read them as booleans, which is why JSON to YAML quotes them.

How do I convert YAML to JSON on the command line?

With yq: yq -o=json file.yaml. With Python: python -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin)))' < file.yaml.

Can I convert a Swagger or OpenAPI YAML file to JSON?

Yes. Swagger and OpenAPI definitions are ordinary YAML, so paste an openapi.yaml or swagger.yaml file to get the equivalent JSON, or paste swagger.json to get YAML. $ref values are kept as they are, not resolved.

Is my data safe?

Processing happens locally in your browser. Tool input is not sent to CodeUnpack servers.

Does it work offline?

Once the page has loaded, this tool can process input without an internet connection.

More converters tools

View all