JSON to YAML Converter

Indent

Converted output will appear here

Paste JSON on the left or load a sample

READY
LN 1, COL 10 CHARS

About the JSON to YAML Converter

The JSON to YAML Converter turns RFC 8259 JSON into YAML and YAML back into JSON, in your browser, using js-yaml and its default schema, which follows YAML 1.2 rules for booleans. Multi-document YAML (documents separated by `---`) converts to a JSON array, so a whole `kubectl get -o yaml` dump or a rendered Helm chart can be pasted at once. Because of the YAML 1.2 rules, the YAML 1.1 "Norway problem" does not apply: `NO` and `yes` stay strings. Use it to translate Kubernetes manifests, GitHub Actions workflows, OpenAPI specs, and Helm values between the format your tools expect and the format people want to read. Conversion runs in your browser and nothing is sent to our servers or analytics, and the input is not saved in the page address; it goes into a link only when you click Share, so avoid sharing manifests that contain secrets.

Updated: November 9, 2026

How to use the converter

  • Paste or drop your JSON or YAML into the input area. When the input box was empty, the direction is picked from the first non-space character of what you add: `{` or `[` means JSON, anything else means YAML.
  • Use the JSON to YAML and YAML to JSON buttons to set the direction yourself. The output panel updates as you type, and Swap moves the output back into the input.
  • For YAML output, choose 2-space or 4-space indentation. For JSON output, choose 2 spaces, 4 spaces, or minified.
  • Multi-document YAML becomes a JSON array with one element per document, and the status bar shows how many documents were found. Empty or null documents, such as the one after a trailing `---`, are skipped. If only one document is left, it converts to a plain object or value.
  • Copy the result, or click Save to download it as `converted.yaml` or `converted.json`.

Worked example: a multi-document Kubernetes manifest

  • Input (YAML, two documents): `apiVersion: v1`, `kind: Service`, `metadata: {name: web}`, then a `---` line, then `apiVersion: apps/v1`, `kind: Deployment`, `metadata: {name: web}`.
  • Output (JSON): `[{"apiVersion":"v1","kind":"Service","metadata":{"name":"web"}},{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"name":"web"}}]`, pretty-printed with your chosen indent.
  • Going the other way, the JSON array converts to a single YAML sequence (`- apiVersion: v1 ...`), not back into separate `---` documents. To get a multi-document file again, use `yq` as shown below.

Command-line alternatives: yq and Python

  • yq (mikefarah/yq v4): `yq -o=json . file.yaml` converts YAML to JSON; for a multi-document file, `yq ea -o=json '[.]' file.yaml` collects the documents into one JSON array. `yq -p=json -P . file.json` converts JSON to YAML, and `yq -p=json -P '.[] | split_doc' list.json` writes each array element as its own `---` document.
  • Python with PyYAML: `python -c "import sys, json, yaml; print(json.dumps([d for d in yaml.safe_load_all(sys.stdin) if d is not None], indent=2, default=str))" < file.yaml` converts every non-empty document into one JSON array; `default=str` stops unquoted dates from raising a TypeError. For the reverse, `python -c "import sys, json, yaml; print(yaml.safe_dump(json.load(sys.stdin), sort_keys=False))" < file.json`. PyYAML follows YAML 1.1, so `NO` and `yes` become booleans there, unlike in this tool. In Windows PowerShell, pipe the file with `Get-Content file.yaml | python -c ...` instead of using `<`.
  • Use the command line when the file is large, contains secrets, or is part of a script; use this page for quick checks and copy-paste work.

Common use cases

  • Kubernetes manifest editing. Convert a manifest to JSON to work on it with jq or a JSON Schema validator, then convert back.
  • GitHub Actions and GitLab CI workflows. Workflow files are YAML; pasting an example from documentation into a JSON-driven config system requires a format swap.
  • OpenAPI and Swagger specs. Many specs are written in YAML for readability while tooling sometimes wants JSON. The structure is kept as-is.
  • Helm values translation. `values.yaml` is the canonical Helm input; some downstream tooling consumes JSON.
  • JSON Schema authoring. Schemas can be written in YAML and converted to JSON for validators that only accept JSON.

Privacy and security

Conversion uses js-yaml and the native `JSON.parse` / `JSON.stringify`, all inside your browser tab, and no request carries your document. Nothing is sent to our servers or analytics. Your direction and indent settings are saved in the page address as you type; the pasted document is not, so it is not sent to our CDN on reload and does not stay in browser history. The document goes into a link only when you click Share. Long input is compressed with lz-string, which is not encryption, so anyone with the link can read it. Remove secrets, API keys, and internal hostnames before sharing a link. A shared link stays in the recipient's browser history and in any app the link passes through.

Tips and pitfalls

  • YAML 1.1 vs 1.2 booleans, the Norway problem. In YAML 1.1, `yes`, `no`, `on`, `off`, and the country code `NO` all parse as booleans. YAML 1.2 dropped these to align with JSON, and this converter always uses 1.2 rules. If the file will be read by a YAML 1.1 parser (PyYAML, older Ansible or Symfony), quote such values: `country: "NO"`.
  • Anchors and aliases. YAML `&name` defines a node and `*name` reuses it. When converting YAML to JSON, each alias is replaced by its own copy of the data. When converting JSON to YAML, the output never contains anchors; repeated structures are written out in full.
  • Comments are lost. JSON has no comment syntax, so YAML to JSON drops every `#` comment, and converting back cannot restore them. If comments matter, edit the YAML directly.
  • Indentation matters in YAML. Items in the same block must line up exactly; a stray space is a parse error, and the error message gives the line and column. The output is always re-indented to the width you choose.
  • Dates become timestamps. An unquoted `2024-01-01` is read as a date and written to JSON as `"2024-01-01T00:00:00.000Z"`. Quote it (`"2024-01-01"`) to keep the original string.
  • Multi-document YAML. If your downstream tool expects only the first document, take element `[0]` of the JSON array.

Frequently Asked Questions

Does the converter support YAML 1.2?
Yes, for booleans and nulls. js-yaml 4 uses its default schema, which follows YAML 1.2: only `true` and `false` are booleans, and `yes`, `no`, `on`, and `off` stay strings. The default schema also adds a few YAML 1.1 types: unquoted dates such as `2024-01-01` become timestamps (`"2024-01-01T00:00:00.000Z"` in the JSON), and `<<` merge keys are resolved. There is no strict 1.2 or 1.1 mode; quote values you want kept as strings.
Is multi-document YAML supported?
Yes. Documents separated by `---` become a JSON array with one element per document, in order. Empty or null documents are skipped, and a file with one remaining document converts to a plain object. In the JSON to YAML direction a JSON array becomes one YAML sequence; this tool does not write `---` separated output, but `yq -p=json -P '.[] | split_doc' list.json` does.
Are anchors and aliases preserved?
No. YAML to JSON resolves each alias into a full copy, because JSON has no references. JSON to YAML never emits anchors, even when the same structure appears more than once.
Are comments preserved?
No. js-yaml does not keep comments when parsing, so YAML to JSON drops them all, and JSON to YAML has none to emit.
What is the Norway problem?
In YAML 1.1, the country code `NO` parses as the boolean `false` because `no` is one of the implicit boolean words. YAML 1.2 dropped `yes`, `no`, `on`, and `off` as booleans. This converter uses 1.2 rules, so `NO` stays the string "NO".
Is round-trip conversion safe?
JSON to YAML to JSON gives back the same data. Key order is kept, except that `JSON.parse` always moves integer-like keys such as `"2"` first, and integers above 2^53 lose precision when the JSON is parsed. YAML to JSON to YAML loses comments, expands anchors into copies, and turns a multi-document file into a single sequence. For files where those details matter, edit the YAML directly.
How do I convert YAML to JSON on the command line?
With yq v4: `yq -o=json . file.yaml`, or `yq ea -o=json '[.]' file.yaml` to collect every document into one array. With Python and PyYAML: `json.dumps([d for d in yaml.safe_load_all(f) if d is not None], default=str)`. PyYAML uses YAML 1.1 rules, so its results can differ from this tool for values like `yes` or `NO`.
When should I pick YAML over JSON for a new project?
When the file will be read or edited mostly by people: Kubernetes manifests, CI/CD workflows, application configs. JSON is better for machine-to-machine transport (APIs, log records, structured events) where strict parsing and minimal whitespace matter.
When should I pick JSON over YAML?
When the document is generated by a program and consumed by another program. JSON has stricter, simpler semantics (no implicit type coercion, no significant indentation, no anchors or aliases), which makes parsing and validation predictable across languages.
Where can I read the standards?
RFC 8259 is the JSON spec (short and strict). YAML 1.2.2 is the current YAML spec. The js-yaml README on GitHub covers its schemas and options.