JSON ↔ YAML Converter

Convert JSON to YAML or YAML to JSON in one click, for Kubernetes, Docker Compose, CI pipelines and OpenAPI specs.

Runs 100% in your browser. Nothing you paste is uploaded or stored.
JSON or YAML input
Result
Ready.

How to use the JSON ↔ YAML converter

  1. Choose the direction: JSON → YAML or YAML → JSON.
  2. Paste your document into the input box, or type it directly.
  3. The converted output appears instantly. If the input is invalid, the error message points to the line that could not be parsed.
  4. Copy the result into your manifest, pipeline file or API client.

The conversion runs entirely in your browser, so configuration files containing internal hostnames or credentials are never uploaded or stored on our servers.

JSON and YAML: the same data, two notations

JSON (JavaScript Object Notation) and YAML (YAML Ain't Markup Language) describe the same basic structures: mappings (objects with key–value pairs), sequences (arrays) and scalars (strings, numbers, booleans and null). Since YAML 1.2, every valid JSON document is also valid YAML, which is why converting JSON to YAML is lossless. Going the other way is usually lossless too, but YAML has features JSON lacks, such as comments, anchors and multi-line block strings, and those are flattened or dropped when you produce JSON.

Developers convert between the two all the time:

  • Kubernetes manifests are normally written in YAML, while kubectl get -o json and the API itself speak JSON.
  • Docker Compose files (compose.yaml) are YAML; converting to JSON helps when generating them from scripts.
  • GitHub Actions and most CI systems define workflows in YAML.
  • OpenAPI specifications can be written in either format, and many tools accept both.

Here is the same object in both notations:

{"service": "web", "replicas": 3, "ports": [80, 443], "debug": false}
service: web
replicas: 3
ports:
  - 80
  - 443
debug: false

Common YAML pitfalls

The "Norway problem"

YAML 1.1 treats unquoted yes, no, on, off, y and n (in various capitalisations) as booleans. A list of country codes therefore turns Norway into false in parsers that follow YAML 1.1:

countries:
  - GB
  - NO     # YAML 1.1: false   YAML 1.2 core schema: "NO"
  - SE

YAML 1.2 restricts booleans to true and false, but many widely used libraries still default to 1.1 behaviour. The safe habit is to quote any string that could be mistaken for another type: "NO", "on", "1.10", "0755". Version numbers are a classic trap: unquoted 1.10 becomes the number 1.1.

Indentation

YAML uses indentation to express nesting, and tabs are not allowed for indentation. A single misaligned space changes the structure or breaks parsing:

spec:
  containers:
    - name: app
      image: nginx
     ports:          # one space short: parse error
        - containerPort: 80

Anchors and aliases

YAML lets you define a block once with &name and reuse it with *name, often combined with the merge key <<. JSON has no equivalent, so the converter expands every alias into a full copy:

defaults: &defaults
  restart: always
  logging: json
web:
  <<: *defaults
  image: nginx

Note that the merge key is a YAML 1.1 extension; not every parser supports it.

Tips for clean conversions

  • Comments (# ...) are discarded when converting YAML to JSON, because JSON has no comment syntax. Keep the YAML file as the source of truth if comments matter.
  • Multi-line block strings (| keeps line breaks, > folds them into spaces) become ordinary strings with \n escapes in JSON.
  • Large integers beyond 253 may lose precision in JavaScript-based tools. Quote IDs that must stay exact.
  • To tidy the result further, run it through the JSON formatter or the YAML formatter & validator.
Tip: A file can contain several YAML documents separated by ---, as Kubernetes bundles often do. JSON has no such concept, so split multi-document files before converting, or expect only one document in the output.

Frequently asked questions

Is every JSON file valid YAML?

Under YAML 1.2, yes: it was designed as a superset of JSON. You can feed JSON straight into most YAML parsers. Converting to block-style YAML simply makes it easier to read and edit.

Why did my YAML value change type after conversion?

Unquoted scalars are resolved by the parser. Values like no, off, 1e3, 0x1F or 2024-01-01 may become booleans, numbers or dates depending on the YAML version and library. Quote them to keep them as strings.

Can I use tabs in YAML?

No. The YAML specification forbids tab characters for indentation. Use spaces, typically two per level, and configure your editor to insert spaces automatically.

Will comments survive a round trip?

No. Comments disappear as soon as YAML is turned into JSON, and they cannot be recovered when converting back. Keep comments in the original YAML file.

Copied to clipboard