JSON to YAML Converter

Paste JSON and get clean, block-style YAML for Kubernetes manifests, CI pipelines and config files.

Overview

JSON is what APIs, kubectl get -o json and most programming languages produce, but the files people edit by hand, such as Kubernetes manifests, Helm values, Docker Compose files and CI pipelines, are almost always YAML. This converter parses your JSON, reports the exact line and column of any syntax error, and writes the same data as indented block-style YAML that is easy to read in a code review.

The output is produced by js-yaml, a widely used YAML library, running in your browser. Nothing you paste is uploaded. Strings that a YAML parser could misread, such as yes, 010 or a: b, are quoted automatically, so the YAML loads back into exactly the JSON you started with.

How to convert JSON to YAML

  1. Paste JSON into the left pane or use Open file. The YAML appears as you type; Ctrl/⌘+Enter converts immediately.
  2. Pick an indent of 2 or 4 spaces. Two is the convention for Kubernetes and GitHub Actions.
  3. Set Wrap to control long strings. At 80 columns, long text is written as a folded >- block; choose No wrapping to keep each value on one line.
  4. Choose a quote style. "When needed" quotes only strings that would otherwise change meaning; Always double quotes every string, which some teams prefer for consistency.
  5. Turn on Sort keys for stable, diff-friendly output, then copy or download the .yaml file.

⇄ YAML to JSON opens the YAML to JSON converter with your result loaded, which is a quick way to confirm the round trip.

Kubernetes and CI use cases

A common workflow is exporting a live object and turning it into a manifest you can commit:

kubectl get deployment web -o json > web.json
# paste web.json here, then delete status, metadata.uid,
# metadata.resourceVersion and other server-managed fields

kubectl accepts JSON manifests as well as YAML, so the conversion is about readability rather than compatibility. The same goes for API responses you want to turn into Helm values.yaml defaults, or JSON emitted by Terraform or a script that has to become an Ansible variables file.

CI systems are stricter. GitHub Actions reads workflows only from .yml or .yaml files in .github/workflows, and GitLab reads .gitlab-ci.yml. If you generate pipeline definitions with a script, emitting JSON and converting it is often simpler than templating YAML text by hand, because you never have to worry about indentation inside string concatenation.

How JSON types map to YAML

JSONYAML outputNotes
Objectkey: value mappingKey order is kept, except that integer-like keys such as "10" come first, because that is how JavaScript orders object properties.
Array- item sequenceEmpty arrays and objects are written as [] and {}.
StringPlain, quoted or block scalarStrings containing newlines become | literal blocks.
Number42, 3.14Integers above 253 lose precision when the JSON is parsed. Quote very large IDs in the source JSON.
Boolean / nulltrue, false, nullUnchanged.

When YAML strings need quotes

YAML guesses the type of an unquoted value, so some JSON strings would turn into something else if they were written bare. The converter quotes these for you; this is what to watch for when you edit the result by hand:

enabled: 'yes'        # bare yes/no/on/off/y/n are booleans in YAML 1.1 parsers
zip: '02134'          # leading zero: bare 02134 is a number (octal in YAML 1.1)
version: '1.10'       # bare 1.10 is the float 1.1
time: '12:30'         # bare 12:30 is the integer 750 in YAML 1.1 (base 60)
greeting: 'a: b'      # ": " inside a plain value starts a new mapping
channel: '#general'   # a leading # starts a comment
note: 'x #y'          # " #" ends the value and starts a comment
empty: ''             # a bare empty value is null, not an empty string
nothing: '~'          # ~ is null

The quoting is deliberately conservative. js-yaml follows YAML 1.2, where yes is just a string, but it still quotes YAML 1.1 booleans because the file may later be read by an older parser such as PyYAML. Kubernetes label values and environment variables are a common place where an unquoted on or no causes a type error at apply time.

Comments and other things JSON cannot carry

JSON has no comment syntax, so the YAML you get has no comments either. If you are converting a file that started life as commented YAML, converted to JSON and edited by a tool, the original comments are gone and need to be restored from version control. The same applies to anchors and aliases: the output never uses & or *, so repeated blocks are written out in full. That is longer, but it is what most reviewers and tools expect.

Duplicate keys are another silent loss. RFC 8259 only says object names SHOULD be unique, and JSON.parse keeps the last value, so {"a": 1, "a": 2} becomes a: 2. Run the input through the JSON validator first if you suspect duplicates.

Frequently Asked Questions

Is my JSON uploaded anywhere?

No. Parsing and conversion run in your browser with JavaScript. Your last input is kept in your browser's local storage so it survives a refresh; click Clear to remove it.

Why does the output quote some values and not others?

Only strings that a YAML parser could read as a different type, or that contain characters with special meaning such as : and #, are quoted. Choose "Always double" if you want every string quoted.

Why is my long string split across lines?

With wrapping at 80 or 120 columns, long strings are written as folded block scalars (>-). They load back as the same single-line string. Choose "No wrapping" if you prefer one line per value.

Can I convert several Kubernetes objects at once?

Paste a JSON array and you get a YAML sequence. For a multi-document file separated by ---, convert each object separately, or use kubectl get -o yaml, which returns a List object.

Why did my large number change?

JavaScript numbers are 64-bit floats, so integers above 9,007,199,254,740,991 are rounded when the JSON is parsed. Store such IDs as strings in the JSON.