StackPractices

YAML ↔ JSON Converter & Validator

Convert YAML to JSON and JSON to YAML without losing multi-document structure. Validate common Kubernetes resources structurally, compare YAML 1.1 and 1.2 behavior, open local files and catch exact syntax errors before they break production. Everything runs locally in your browser.

1. Input
or drop a .yaml, .yml or .json file here — it is read locally

Multi-document input is welcome: Kubernetes manifests, Helm output, docker-compose files and CI config with --- separators are parsed document by document.

2. Options
JSON/YAML schema or CRD manifest
Privacy: conversion runs entirely in your browser. Small inputs may be encoded in the URL hash so a share link reproduces the state; do not share that link if the configuration is sensitive.

JSON output

YAML vs JSON: what actually changes

YAML and JSON overlap, but they are not interchangeable syntaxes. JSON is a strict data format with six types and no comments. YAML is a document format with comments, anchors, tags, multiple documents and several scalar resolution rules. A faithful converter therefore has to do more than replace indentation with braces: it has to tell you which YAML features cannot exist in JSON.

Feature YAML JSON
CommentsSupported with #Not supported
Multiple documentsSeparated by ---One value per JSON text; represented here as an array
ReferencesAnchors and aliasesNo references; values must be duplicated
Object keysCan be non-string scalarsAlways strings
TagsExplicit type metadata such as !!binaryNo tag metadata

JSON Lines for pipelines

Pretty JSON is useful for review, but pipelines often need one value per line. The JSON Lines output emits each YAML document as a compact JSON object on its own line, producing a .jsonl stream that is easier to consume with logs, batch jobs and Unix tools. The normal JSON output remains available when you need a single top-level array.

Why multi-document YAML breaks most converters

Kubernetes manifests, Helm output and CI pipelines often contain several YAML documents separated by ---. Many online converters parse only the first document or flatten the rest away. That is dangerous: a ServiceAccount, Deployment and NetworkPolicy are independent objects and their order matters when you review or transform the manifest.

This converter parses every document and preserves order. In YAML → JSON mode the result is a top-level JSON array: element 0 is document 1, element 1 is document 2, and so on. In JSON → YAML mode, enabling the multi-document option turns each element of a top-level array back into a separated YAML document. The numbered document list above the output makes it clear what was parsed.

Kubernetes structural validation per document

Valid YAML is not necessarily a valid Kubernetes object. A manifest can parse perfectly and still fail in a cluster because a Deployment has no selector, a Service port is outside the valid range, template labels do not match the selector or a field name was invented. When a document contains apiVersion and kind, the tool applies built-in structural checks and reports the document number plus the exact object path.

The checks cover common workload, networking and RBAC resources such as Deployment, Service, ConfigMap, Secret, Ingress, StatefulSet, DaemonSet, Job, CronJob, ServiceAccount, Role and RoleBinding. They are intentionally local and static: they catch structural mistakes, unknown fields in common spec objects, missing required fields and invalid enum values, but they do not replace the complete schema validation performed by a Kubernetes API server or admission policies.

CRDs, Helm templates and inspection workflow

Custom resources can be validated with your own schema. Upload a CRD manifest in YAML or JSON and the tool extracts the OpenAPI schema for each served version, then matches documents by group, version and kind. You can also upload a compact schema wrapper when the resource is not described by a full CRD manifest. Everything stays in the browser.

Helm input is checked statically for unclosed actions, stray delimiters and block endings before the YAML parser reports its own error. The tree view turns the parsed object into expandable nodes for inspection, error locations jump directly to the matching textarea line, and the report button exports a Markdown summary with parser errors, conversion warnings, Kubernetes findings, Helm lint results and YAML 1.1 comparisons.

The yes/no/on/off trap and the Norway problem

YAML 1.1 treated yes, no, on and off as booleans. YAML 1.2 removed that rule, but the ecosystem did not move in lockstep. Kubernetes users still hit the classic Norway problem: the country code NO becomes false in a YAML 1.1 parser. The same thing happens to feature flags written as enabled: yes.

This tool uses YAML 1.2 core semantics in strict mode, so those tokens remain strings here. When they appear unquoted, the comparison panel shows how YAML 1.1 would resolve the same scalar: NO to false, yes to true and 0777 to octal 511. If the value is meant to be a string, quote it. If it is meant to be a boolean, write true or false.

Leading-zero numbers are not file permissions

Values such as 0777 are another production classic. YAML 1.1 parsers may interpret them as octal numbers, while YAML 1.2 parsers often treat them as decimal numbers. Neither behavior matches the intent when the value is a Unix file mode string. The converter warns about leading-zero numeric scalars; quote them as "0777" when they represent permissions, identifiers or pins.

Anchors and aliases are expanded, not preserved

YAML anchors reuse a subtree without repeating it:

defaults: &defaults
  retries: 3
  timeout: 30
service:
  <<: *defaults
  name: api

JSON has no reference mechanism, so conversion must duplicate the referenced values. The tool resolves aliases and tells you which references were expanded. That duplication is correct for data exchange, but it means the JSON output can be larger and no longer proves that two values were originally shared.

Validate and format the JSON output

If you need to inspect the resulting JSON more deeply, compare two versions or locate a JSON syntax error, open the JSON Formatter, Validator & Diff. The two tools are designed to work together: convert configuration here, then format or diff the structured JSON there.

Frequently asked questions

How do I convert YAML to JSON online?

Paste YAML into the input panel and the converter parses it locally with js-yaml, validates it and prints equivalent JSON with indentation. Syntax errors show the exact line and column, including the offending line. Nothing is uploaded to a server.

How do I convert multi-document YAML to JSON?

Multi-document YAML is parsed document by document. The JSON output is a top-level array in which each element corresponds to one YAML document in order, and the interface labels each parsed document with its number and type. This is the correct representation for Kubernetes manifests that use --- separators.

Does this tool validate Kubernetes manifests?

Yes. Documents with apiVersion and kind are checked locally against built-in structural rules for common Kubernetes resources. The report includes the document number and object path for missing fields, invalid values, mismatched selectors and unknown fields in common spec objects. It is not a complete replacement for API server schema validation or admission policies.

Why does YAML sometimes turn no or yes into booleans?

YAML 1.1 treated yes, no, on and off as booleans. YAML 1.2 removed that behavior, but many older parsers still follow YAML 1.1. This converter uses YAML 1.2 semantics and shows how the same unquoted values would resolve in YAML 1.1, because a value such as the country code NO can become false in another parser.

What happens to YAML anchors, aliases and comments in JSON?

Anchors and aliases are resolved before conversion, so the referenced values appear expanded in the JSON output. JSON cannot represent references, comments or YAML tags, so the tool shows explicit warnings whenever that information cannot survive the conversion.

Can JSON become multi-document YAML?

Yes. Enable the multi-document option in JSON to YAML mode and a top-level JSON array is emitted as one YAML document per array element, separated by --- lines. Without that option the array remains a normal YAML array.

Is it safe to paste Kubernetes manifests or secrets here?

Conversion and validation run entirely in client-side JavaScript. Your input is not sent to a backend. For shareable states, small inputs are encoded in the URL hash on your machine; large inputs are not. Do not share a generated link if it contains sensitive configuration.

Related resources