JSON to YAML Converter

Paste a config blob, a Kubernetes manifest, or an API response and get YAML back in the shape you want. Choose the indent, decide how far down the tree stays block style, sort the keys, and read which of your string values an older YAML parser would turn into booleans or numbers.

JSON in

0 B

YAML out

0 B

Load a sample below or paste your own JSON.

0YAML lines
0Keys
0Max depth
01.1 traps
0%Size change
Try one

YAML swaps punctuation for whitespace

Both formats describe the same three things: mappings, sequences, and scalars. JSON marks the boundaries with braces, brackets, and commas, so a file survives being flattened onto one line. YAML marks them with indentation and a dash, so the shape of the file is the data. Every brace you delete moves meaning into a column position.

InputJSON
{"service": {"port": 8443,"regions": ["eu-west-1", "us-east-2"]}}
OutputYAML
service:port: 8443
regions:- eu-west-1
- us-east-2

Two practical consequences follow. Tabs are illegal as indentation anywhere in a YAML document, so an editor set to hard tabs breaks the file the first time somebody adds a line by hand. And a stray space in front of a key reparents it under the previous entry without any error, because the result is still a legal document, just a different one. The output here uses spaces only and keeps the indent constant at whatever the control is set to.

The quoting question, and why NO turns into false

This is the failure that costs people an afternoon. YAML 1.1, published in 2005, resolved a long list of bare words to booleans: y, yes, on, true, and their negatives. YAML 1.2 dropped all of them except true and false. Plenty of live parsers still run 1.1 rules, including PyYAML in its default configuration and the Ruby standard library, so a country list written with Norway in it becomes a list with false in it.

Your JSON stringBare in YAML 1.1Where this bites
"NO"falseISO country codes, Norway and Nigeria both affected
"on" / "off"true / falseFeature flags and switch labels stored as words
"0755"493File modes, a leading zero reads as octal
"12:30"750Times and durations, colons read as base 60
"1.20"1.2Version numbers, the trailing zero is gone
"null"~Literal placeholder text that becomes an absent value

Leave YAML 1.1 safe quoting ticked and every token in that table ships wrapped in quotes, which holds it as a string under both specification versions. Untick it and the boolean words and the sexagesimal times go bare, which is shorter to read and correct when you know the consumer is a 1.2 parser such as Go's yaml.v3 or JavaScript's js-yaml.

Two rows behave the same either way. A leading-zero string like 0755 and a decimal like 1.20 stay quoted in both modes, because those read as numbers under YAML 1.2 as well, and dropping the quotes would corrupt the value for every parser rather than only the old ones. That is why the panel under the converter reports each token as Bare or Quoted against the YAML actually sitting in the right pane, instead of assuming the switch settles it. The 1.1 traps tile counts the distinct tokens found, and the panel lists up to ten of them.

Quote every string is a different setting

The Quote every string switch is blunt by design. It puts double quotes around all text values, including plain words that need no protection. Output gets noisier, and diffs get larger, but ambiguity drops to zero. Reach for it when the YAML feeds a parser you have never tested, or when a config repository has already been bitten once and the team wants a rule instead of a judgment call.

Line breaks turn into block scalars

A JSON string holds newlines as the two characters \n. YAML writes real line breaks instead, using a block scalar marked with a pipe. That is far easier to read, and it changes what a diff looks like when somebody edits one sentence in a long description.

InputJSON
{"readme": "First line.\nSecond line."}
OutputYAML
readme: |-
First line.
Second line.

The - after the pipe is the chomping indicator. It says the value ends after the last visible character with no trailing newline, which matches what the JSON string actually contained. A bare | would add one newline at the end and |+ would keep all of them. Getting this wrong is how a copied SSH key or certificate stops validating, so the exact marker matters more than it looks.

The Line width control governs when long single line strings get folded across several lines. Set it low and the file becomes a narrow column that survives side by side code review. Set it to 200 and most values stay on one line. Folding never changes the value, because YAML rejoins folded lines with a space when it reads them back.

Flow style, for the parts that read better inline

Block style is the default and is what people picture when they picture YAML. Flow style is the JSON-shaped alternative, and YAML accepts it because JSON is a valid subset of YAML 1.2. Mixing the two is normal in hand written config, where the top of the tree is spread out and the leaves are compact.

Block all the way downtall
limits:cpu:- 100m
- 500m
Inline below level 1compact
limits: {cpu: [100m, 500m]}

Pick the level where detail stops mattering. A manifest with fifty short label pairs reads better with those pairs inline and the structure above them expanded. Going fully inline defeats the point of converting at all, since the result is close to the JSON you started with.

What the counters are telling you

Sorting keys changes more than the order

Ticking Sort keys alphabetises every mapping at every level. That makes two generated files comparable, which is the reason it exists: a diff between yesterday's export and today's stops being noise the moment both are sorted. The cost is readability. A Kubernetes manifest with apiVersion and kind at the top is following a convention, and sorting pushes apiVersion above kind while dropping spec and metadata wherever the alphabet puts them. Sort machine to machine files. Leave files a person maintains alone.

Anchors and aliases will never appear in this output, and that is not a missing option. YAML deduplicates repeated structures with an anchor such as &defaults and a reference such as *defaults. Those exist in the document object graph, not in the text. Parsing JSON produces a fresh object for every brace, so nothing in the tree is shared and there is nothing to anchor. If your config repeats the same block six times and you want one definition with five references, that restructuring happens in the YAML by hand. No converter can infer it, because the JSON never recorded that the six blocks were meant to be the same thing.

Where this page stops

Comments are not generated, since JSON has nowhere to store them. If the YAML you are producing replaces a file that had comments, copy them across before you commit, because a comment-free config is the most common regression from an automated conversion.

Multi-document output is not supported either. YAML separates documents with --- between them, and Kubernetes users often keep several resources in one file. The Start with --- switch adds a single opening marker for tools that expect one, and no more than that. Split the resources yourself, or convert them one at a time.

Custom tags such as !!binary, dates as real timestamp nodes, and complex keys are all outside what JSON hands over. A date in JSON is a string, so it stays a quoted string here rather than becoming a YAML timestamp. Some parsers accept the string and coerce it later, others need the tag, and guessing which would break more files than it fixes.

Conversion runs entirely in this tab through js-yaml. Nothing is uploaded, so a manifest with real secrets in it stays on your machine, and nothing survives closing the tab. Very large files, past a few megabytes, will make the editors sluggish before the conversion itself becomes the problem.

Pages for the neighbouring jobs

Coming back the other way is handled by YAML to JSON. If the YAML you produce here gets rejected downstream, the YAML validator reports the line and the reason. When the JSON refuses to parse before you get this far, run it through the JSON fixer first, since this page reports the error position and leaves the repair to you. For a document format rather than a config format, JSON to XML covers that side, and the YAML cheat sheet is worth a look when the block scalar markers stop making sense.

Questions people ask with a manifest open

The things that come up once real config is in the left pane.

Why did my country code NO become false?

YAML 1.1 treats yes, no, y, n, on, and off as booleans when they appear without quotes. Parsers such as PyYAML still follow those rules by default. Keep the YAML 1.1 safe quoting option ticked and every affected value ships wrapped in quotes, which holds it as text under both specification versions.

Can I use tabs to indent the output?

No, and no YAML tool will let you. The specification forbids tab characters as indentation, so a file that contains them fails to parse. Pick 2, 4, or 6 spaces from the indent control. Two spaces is the convention across Kubernetes, Docker Compose, and most CI configuration.

What does the pipe followed by a minus sign mean?

That is a block scalar with strip chomping. The pipe says the following indented lines are literal text with their line breaks kept. The minus says no trailing newline belongs to the value. It appears whenever a JSON string contained a line break, and the marker matters for things like certificates where an extra newline breaks validation.

Why is my YAML smaller than the JSON I pasted?

YAML drops the quotes around keys, the braces, the brackets, and the commas. On a typical config that saves 10 to 25 percent of the bytes. Turning on Quote every string puts most of that back, and deeply nested data saves less because indentation grows as punctuation shrinks.

Where are the anchors and aliases?

They cannot be generated from JSON. An anchor records that two parts of a document are the same object, and parsing JSON creates a separate object for every block, so nothing is shared. Deduplicating repeated config into one anchored definition is a manual edit after the conversion.

Do my comments come through?

JSON has no comment syntax, so there is nothing to carry across. If this YAML replaces a hand maintained file, copy the comments over before committing. Losing them is the most common regression when config is regenerated from an export.

Can I output several Kubernetes resources in one file?

Not from a single conversion. YAML splits documents with a three dash line, and this page writes one document. The Start with --- switch adds an opening marker only. Convert each resource separately and join the results with a three dash line between them.

Is any of this sent to a server?

No. Parsing and serialisation both run as JavaScript in this tab using js-yaml, and the editors hold text in browser memory. A manifest containing credentials stays on your machine, and closing the tab discards everything.