JSON ⇄ YAML Converter

Paste JSON to get YAML, or paste YAML to get JSON. Use the swap button to flip direction at any time.

JSON → YAML

🔒 Everything happens inside your browser. Your data is never uploaded or stored.

What are JSON and YAML?

JSON and YAML are two ways of writing structured data. JSON uses curly braces and quotes and is common in web apps and APIs. YAML uses indentation and is popular for configuration files such as Docker, Kubernetes and GitHub Actions.

Worked Example

Here is how a simple server configuration object translates between JSON and clean YAML syntax:

JSON Input:
{
  "service": "web",
  "port": 8080,
  "tags": ["prod", "us-east"]
}
YAML Output:
service: web
port: 8080
tags:
  - prod
  - us-east

Notice how brackets and quotes are replaced by clean indentation, making the YAML structure easier to read and maintain in configuration repositories.

Is my data safe?

Yes. The conversion happens in your browser, so nothing you paste is sent to a server. That makes it safe to use with configuration files that may contain internal names or settings.

Things to know

YAML comments (lines starting with #) cannot exist in JSON, so they are dropped when converting YAML to JSON. If your input has a mistake, the tool shows a plain message explaining what is wrong.

Technical Specification, Standards & Practical Use Cases

YAML 1.2 Specification vs. ECMA-404 JSON Grammar

Since the publication of the YAML 1.2 Specification, YAML ("YAML Ain't Markup Language") has been an official strict superset of JSON (ECMA-404 / RFC 8259). While JSON relies on explicit syntactic delimiters—curly braces {} for associative maps, square brackets [] for ordered sequences, and mandatory double quotes "" around keys and strings—YAML uses Python-style whitespace indentation (strictly spaces, never tabs) and dash-prefixed block sequences to represent hierarchical trees with minimal visual noise.

Scalar Type Coercion Pitfalls (The "Norway Problem" & Version Numbers)

A major source of production configuration bugs is implicit scalar type resolution between YAML 1.1 and YAML 1.2 parsers. Under older YAML 1.1 rules, unquoted tokens such as NO, yes, on, and off were coerced into booleans (famously turning the ISO country code for Norway, NO, into false). Similarly, unquoted version strings like 3.10 can be truncated to the floating-point number 3.1, and leading-zero zip codes like 02115 can be interpreted as octal integers. Our converter uses a strict YAML 1.2 Core Schema parser and serializer that automatically quotes ambiguous strings so version tags, hexadecimal hashes, and country codes remain intact when converting between JSON and YAML.

Multi-Line Block Scalars & Comment Stripping

YAML supports literal block scalars (|, which preserves newlines) and folded block scalars (>, which folds single newlines into spaces), commonly used for embedded shell scripts inside CI/CD workflows. When converting YAML to JSON, multi-line scalars are cleanly serialized into single-line JSON strings with escaped \n sequences, while YAML comments (#) are stripped to satisfy strict RFC 8259 compliance.

Practical DevOps & Cloud-Native Workflows

  • Kubernetes & Helm Manifests: Converting verbose JSON output from kubectl get deployment -o json into clean, version-controlled YAML manifests.
  • OpenAPI / Swagger Specifications: Switching API contract definitions between human-editable YAML and machine-consumable JSON for code generators.
  • GitHub Actions, Docker Compose & Ansible: Validating indentation hierarchy and catching syntax errors in CI/CD pipeline definitions locally in the browser without exposing cloud secrets.

Frequently Asked Questions

How does JSON differ from YAML?

JSON uses curly braces, brackets, and quotes to structure data and is the primary standard for web APIs. YAML uses whitespace indentation and human-readable formatting, making it ideal for configuration files such as Docker Compose, Kubernetes manifests, and CI/CD pipelines.

Are YAML comments preserved when converting to JSON?

No. The official JSON specification does not support comments. Any comment lines starting with # in YAML will be omitted when converting to JSON.

Can I convert in both directions?

Yes. You can paste JSON to generate YAML, or paste YAML to produce JSON. Click the "Swap direction" button at any time to instantly reverse the conversion.

Is my configuration data kept private?

Yes. The parser runs 100% locally in your web browser. Sensitive server settings, API credentials, or internal cluster names pasted into this converter are never transmitted across the network.

Related Tools