Skip to content
FormatKit

Free online JSON to YAML converter

JSON to YAML that quotes what must be quoted

This JSON to YAML converter is free, needs no account and rewrites payloads up to 5 MB in the browser — block style by default, two or four spaces, with short scalar lists kept inline if you switch to flow. The part that matters is the quoting: strings such as no, 0755 and 12:30:00 come back from a YAML reader as a boolean, an octal integer and 45,000 unless they are quoted, so each one is quoted and listed underneath with the reason.

  • 100% free
  • No signup
  • Up to 5 MB
  • Block or flow style
  • Every quote explained
YAML

The YAML appears here as you type.

Paste JSON, open a file, or press Ctrl+V anywhere on this page.

Five strings that change type without quotes

All five values on the left are strings in JSON. The middle column is what a careless writer emits; the right column is what a YAML 1.1 reader hands back from it.

JSON in

{
  "ready": "no",
  "umask": "0755",
  "window": "12:30:00",
  "since": "2026-08-09",
  "note": "deploy: friday"
}

Written without quotes

ready: no
umask: 0755
window: 12:30:00
since: 2026-08-09
note: deploy: friday

the last line will not parse in PyYAML or js-yaml at all; the rest parse into the wrong types

Read back as

false
493
45000
Date(2026-08-09)
—

quoted output keeps all five as the strings they were

0755 becomes 493 because a leading zero means octal in YAML 1.1; 12:30:00 becomes 45,000 because the same version reads colon-separated digits as a sexagesimal number. Neither conversion raises an error, which is what makes them worth catching here rather than in production.

How to convert JSON to YAML

Three steps: paste the payload, choose the style and the reader you are writing for, check the quote list.

  1. Paste the JSON

    Number literals travel through this page as the text you wrote, so a 19-digit snowflake ID and a price spelled 12.50 come out with their digits intact rather than passing through a float on the way. Paste the payload, open a .json file of up to 5 MB, or paste with the keyboard — Ctrl+V, ⌘V under macOS.

  2. Choose the shape and the safety level

    Two or four spaces, block style with one item per line or flow style that keeps short scalar lists inline as [8080, 8443]. Then pick who has to read the result: quoting for YAML 1.1 puts quotes around yes, no, 0755 and 12:30:00 as well, which is what you want for anything parsed by PyYAML, SnakeYAML or Psych; quoting for 1.2 only leaves those bare.

  3. Read the quote list, then copy

    Under the panels, every string that needed quoting is shown with the reason — “it would be read as a timestamp”, “a space before # would start a comment”. Multi-line strings are counted separately because they become | block scalars rather than escaped one-liners. Copy lifts the result; Download writes converted.yaml.

Technical specifications

Accepted inputAny RFC 8259 document; number literals are copied through as written, so a 19-digit ID or a trailing-zero price is not rounded on the way out
Indentation2 or 4 spaces, never tabs, with sequences indented one level under their key
Collection styleBlock throughout, or flow for all-scalar collections that fit within 72 characters — [8080, 8443] and {tier: web, tenant: acme}
Quoting rules16 tests: empty, edge whitespace, leading indicator, ": ", trailing colon, " #", control characters, null, boolean, number, .inf, .nan, timestamp, plus the 1.1-only yes/no/on/off, leading-zero octal and 12:30:00 sexagesimal
Multi-line stringsLiteral | block scalars with |-, | and |+ chosen from the trailing newlines, and an explicit indentation indicator when the first line starts with a space
null and emptiesnull, ~ or nothing after the colon; {} and [] for empty collections, which block style cannot express
Measured output2.83 MB of indented JSON (12,000 records) becomes 1.95 MB of YAML in 0.07 seconds — 31% smaller and 132,000 lines
Round tripReading the result back through this site's YAML parser returns a byte-identical JSON document when the keys are unique; free, no signup, converted in this browser tab

Frequently asked questions

When does a string actually need quotes in YAML?

When leaving it bare would make a reader produce something other than that string — which is a longer list than most people expect. It covers the empty string, anything with leading or trailing spaces, anything starting with an indicator character such as - ? : , [ ] { } # & * ! | > % @ or a quote, anything containing a colon followed by a space or a space followed by #, and anything that resolves to a number, boolean, null, date, infinity or NaN. Everything else can stay plain, which is why 1.2.3 and sh -c come out unquoted here: neither resolves to another type.

Why did the converter put quotes around the word no?

Because a YAML 1.1 reader turns bare no into the boolean false, and most language bindings are still 1.1. This is the Norway problem: a list of country codes containing NO loses Norway and gains a false. The same rule catches y, yes, n, on and off, and it applies to keys as much as values. Switch the target to “YAML 1.2 readers only” and the quotes come off, because the 1.2 core schema resolves only true and false.

How are multi-line strings written?

As a literal block scalar introduced by |, with the text indented underneath instead of escaped into one line. A string ending without a newline gets |-, one ending with a single newline gets plain |, and one ending with several gets |+ — those are the strip, clip and keep chomping indicators, and choosing the wrong one changes the value. A line with trailing whitespace, or a control character anywhere in the string, forces a double-quoted one-liner instead, because a block scalar cannot represent either without ambiguity.

Should I use 2 or 4 spaces, and can I use a tab?

Never a tab — YAML forbids tabs in indentation outright, and no option here will emit one. Two spaces is the convention almost everywhere (Kubernetes, GitHub Actions, docker-compose, Ansible) and is what this page does by default; four is available and equally valid. What actually matters is consistency inside a document, since indentation is the only thing expressing structure.

How are empty objects and empty arrays written?

As {} and [], because block style has no way to spell an empty collection. Those two are the only flow syntax that appears in block mode, and they are worth keeping rather than dropping: a key with nothing after it parses as null, not as an empty map, so omitting the braces would change the value your consumer receives.

Is the YAML smaller than the JSON it came from?

Usually, by around a third: a 2.83 MB indented JSON payload of 12,000 records became 1.95 MB of YAML here, 31% smaller. The saving comes from dropping every quote around a key, every comma at the end of a line, and every brace and bracket — block style spends indentation instead of punctuation. Flow style for short lists gives some of that back and buys compactness in the other direction.

Can I paste the result straight into a Kubernetes manifest or a workflow file?

Yes, and switching on the leading --- makes it a well-formed document in a stream, which is how multi-resource manifests are written. Keep the target set to YAML 1.1 for those, because Kubernetes parses through Go libraries and GitHub Actions through a 1.1-era reader; the extra quotes around yes, no and 0755 are exactly what keeps a mode or a feature flag from changing type when the file is applied.

About writing YAML that reads back correctly

YAML's plain scalar is its best idea and its sharpest edge. Because a bare word needs no quotes, a config file reads like prose — and because a bare word is then matched against a table of patterns to decide its type, the meaning of your value depends on what it happens to look like. So a writer cannot decide quoting from the value alone. It has to know how wide the receiving parser's pattern table is, and those tables differ by specification version — which is why the target is a control on this page rather than a silent assumption baked into the output.

The conservative default is to quote for 1.1, because the installed base is 1.1. PyYAML, SnakeYAML and Ruby's Psych all still resolve the older type set by default, so a file that is safe under 1.2 can silently change meaning when a Python script loads it. The cost of quoting defensively is a slightly noisier document; the cost of not doing it is a deployment where mode: 0644 arrives as the decimal 644 and a permission is wrong. If you want to see both readings of the same file side by side, paste the output into YAML to JSON and flip its schema selector.

One thing this conversion does not lose is data. YAML 1.2 is a superset of JSON, so everything in a JSON document has a home — the round trip through this site's own YAML reader returns a byte-identical document, checked here on a 2.83 MB payload of 12,000 records, provided no object repeats a key. The only irreversible case is a duplicate key, which JSON merely discourages and YAML treats as an error or a last-one-wins merge. Beyond that, block style trades punctuation for indentation and comes out about 31% smaller, which is why the same data is easier to review as YAML and easier to transport as JSON — keep a JSON viewer open for the structure and use YAML for the file people edit, or take the payload straight to JSON to XML when the consumer is older than either.

Where the conversion runs

The payload is parsed and rewritten by JavaScript inside this tab and is never uploaded or stored, so a manifest holding internal hostnames or an API key can be reshaped here without a copy existing anywhere else.