Home Tools Blog About

JSON to YAML Converter

In short

Turns JSON into clean, readable YAML. Strings that YAML would misread, such as NO, on, 1.10 or 0755, are put in quotes, and numbers are copied exactly as written.

  • Runs in your browser
  • Nothing uploaded
  • Free, no sign-up
Runs in your browser; the JSON you paste or open is not uploaded.
🛡
Private by designYour files and text stay in this tab
⚡
Runs in your browserNo waiting for a server
💧
No watermarksClean output you can use
🆓
FreeNo account needed

How to Use JSON to YAML Converter

JSON to YAML Converter · free online tool · All Tools Verse
The JSON to YAML Converter tool, as it looks in your browser.
  1. Paste your JSON, open a .json file, or click Sample.
  2. Pick the indent (2 or 4 spaces) and the other options: quote all strings, | blocks for multi-line text, sorted keys, or one YAML document per array item.
  3. Read the YAML on the right. The notes under it list every string that was quoted and why.
  4. If the JSON has errors, the exact line and column are shown. Click Fix common mistakes to repair comments, single quotes and trailing commas.
  5. Copy the YAML or download it as a .yaml file.

Example: a service config with values YAML would misread

This is the Sample button. It looks like a normal settings file, but five of its strings would change meaning if they were written into YAML without quotes:

{
  "service": "billing-api",
  "version": "1.10",
  "replicas": 3,
  "debug": false,
  "country": "NO",
  "zip": "02134",
  "schedule": "12:30",
  "tags": ["payments", "eu-west", "on"],
  "owner": null,
  "env": {"LOG_LEVEL": "info", "TIMEOUT_MS": 2500},
  "notes": "Restart after deploys.\nCheck the queue first.\n",
  "endpoints": [
    {"path": "/invoices", "methods": ["GET", "POST"]},
    {"path": "/health", "methods": ["GET"]}
  ]
}

The converter returns:

service: billing-api
version: '1.10'
replicas: 3
debug: false
country: 'NO'
zip: '02134'
schedule: '12:30'
tags:
  - payments
  - eu-west
  - 'on'
owner: null
env:
  LOG_LEVEL: info
  TIMEOUT_MS: 2500
notes: |
  Restart after deploys.
  Check the queue first.
endpoints:
  - path: /invoices
    methods:
      - GET
      - POST
  - path: /health
    methods:
      - GET

Look at the quoted values. '1.10' stays a version string instead of becoming the number 1.1. 'NO' and 'on' stay text for tools that follow the older YAML 1.1 rules, where they mean false and true. '02134' keeps its leading zero, and '12:30' is not turned into the number 750. The notes under the result say the same thing in words, so you can see why each quote is there.

The two-line notes string became a | block, which keeps the line breaks readable. Numbers, true, false and null are copied as they were.

How JSON strings come out in YAML

Each row is one JSON string run through the tool with default options. We read every result back with two YAML readers, js-yaml and PyYAML, and both returned the original string.

JSON string YAML written Why
"NO" 'NO' YAML 1.1 readers such as PyYAML read a bare NO as false (the “Norway problem”)
"on" 'on' A bare on is true in YAML 1.1
"yes" 'yes' A bare yes is true in YAML 1.1
"true" 'true' A bare true is a boolean in every YAML version
"null" 'null' A bare null is the null value
"" '' An empty value after the colon would be read as null
"1.10" '1.10' Bare 1.10 is the number 1.1, so the trailing zero would be lost
"0755" '0755' Bare 0755 is the number 755 in YAML 1.2 and octal 493 in YAML 1.1
"1e3" '1e3' Bare 1e3 is the number 1000 in YAML 1.2
"12:30" '12:30' Bare 12:30 is the base-60 number 750 in YAML 1.1
"2024-01-15" '2024-01-15' Many readers turn a bare date into a date object
"key: value" 'key: value' A colon followed by a space starts a new key
"#general" '#general' A # at the start begins a comment
"- item" '- item' A dash and a space start a list item
"*important*" '*important*' A * at the start refers to an anchor (an alias)
" padded " ' padded ' Spaces at the start and end would be dropped
"It's fine" It's fine Nothing here is special, so no quotes are needed
"café" café Accented letters and emoji stay as they are
"line one\nline two" |-
line one
line two
Line breaks become a | block; the – drops the final newline

How it works

  • The JSON is read with a strict parser. An error reports the line and column, and the optional fixer repairs comments, single quotes, unquoted keys, trailing commas and Python values such as True and None, then lists each change.
  • Numbers are copied character for character. 12345678901234567890 and 1.50 are not rounded or reformatted, which a converter built on JSON.parse cannot promise.
  • A string is left bare only when every YAML reader will read it back as the same text. Anything that looks like a number, a boolean, null or a date in YAML 1.2 or YAML 1.1, starts with a YAML symbol, contains : or #, or has spaces at either end is quoted.
  • Single quotes are used where possible. Control characters such as tabs inside a value, or a lone carriage return, switch to double quotes with escapes like \t and \u0001.
  • Multi-line strings become literal blocks. The block header shows how the final line breaks are kept: |- for none, | for one, |+ for more. Text that starts with spaces also gets an indent number, as in |2-.
  • Keys follow the same quoting rules, so a key such as on or 12 comes out as 'on' or '12'.

Limits

  • JSON has no comments, so the YAML has none either. Add them by hand after converting.
  • Repeated blocks are written out in full. The tool does not create anchors (&name) and aliases (*name) for you.
  • If a key appears twice in the JSON, YAML cannot hold both, so the last value is kept and a warning names the key.
  • Numbers in exponent form such as 1e5 stay as written. YAML 1.2 reads them as numbers, but PyYAML reads them as text, so the tool warns you when it sees one.
  • Very large files work, but the result box gets slow to scroll past a few megabytes. Downloading the .yaml file is easier then.

Frequently asked questions

Why is NO in quotes in my YAML?

In YAML 1.1, a bare NO, no, off or n is read as false. That spec is old, but PyYAML and several other common libraries still follow it, so country codes such as Norway’s NO turned into false in real projects. Quoting the value keeps it text for every reader.

Is JSON already valid YAML?

Almost always. YAML 1.2 was designed so that JSON documents are valid YAML, and the YAML to JSON converter reads JSON input without complaint. Converting still helps, because YAML without braces and quotes is easier to read and edit by hand.

How do I turn a JSON array into several Kubernetes manifests?

Turn on “Top-level array as separate documents”. Each item of the array becomes its own YAML document starting with —, which is the format kubectl apply -f expects for a multi-object file.

Can I check the YAML before I use it?

Paste it into the YAML validator. It reports syntax errors by line and warns about values that YAML 1.1 and YAML 1.2 read differently.

Keep going

Related Tools

All Document tools →
Share

Embed this tool

Add this free tool to your website. Copy and paste the code: