YAML ⇄ JSON Converter
Convert YAML to JSON and JSON back to YAML in your browser. Handles nested maps, sequences, block scalars and inline flow style, with a key count.
Convert between YAML and JSON in either direction, with the indentation you choose. Useful when a tool speaks one format and your file is in the other, and when you want to see exactly what structure a piece of YAML actually describes.
Paste some YAML...
// YAML ⇄ JSON Converter: Features
Why YAML needs checking more than JSON does
YAML is designed to be pleasant to write, and that pleasantness comes from indentation carrying meaning. The cost is that a structure can be wrong without looking wrong: a key indented two spaces too far becomes a child rather than a sibling, and the file still parses. Converting to JSON makes the nesting explicit with braces and brackets, which is often the quickest way to confirm that a manifest describes what you intended.
What the converter handles
Nested mappings and sequences, inline flow style with braces and brackets, block scalars in both the literal and folded forms, quoted and unquoted strings, inline comments, and automatic typing of numbers, booleans and null. Going the other way, JSON is emitted as conventional block-style YAML with the indentation you select. The key count under the output is a quick sanity check that nothing was dropped.
The Norway problem and other surprising types
YAML infers types from unquoted values, and the rules have caught out a great many people. In the original specification, the unquoted word no is a boolean, which famously turns the country code for Norway into false. Similarly, a version number written as 1.10 becomes the number 1.1, and a value like 08 can be rejected as an invalid octal. The fix in every case is to quote the value. Converting to JSON shows you immediately whether a value was read as a string or as something else.
Where each format belongs
YAML wins for anything a person edits by hand: it allows comments, avoids the punctuation noise, and handles multi-line strings gracefully, which is why Kubernetes manifests, CI pipeline definitions and Docker Compose files are written in it. JSON wins for anything a machine produces or consumes: it is unambiguous, parses fast, has one obvious representation, and cannot express the alias and anchor features that make YAML hard to reason about.
Kubernetes manifests stay on your machine
Parsing and serialisation run as JavaScript in your browser. Manifests naming internal services, pipeline files containing secret references and configuration for unreleased systems are all safe to paste, because nothing is transmitted, stored or logged. To convert to or from other configuration formats, the TOML, CSV and XML converters work the same way.
// YAML ⇄ JSON Converter: FAQ
What does this convert?
- YAML into JSON, and JSON into YAML, with a choice of indentation for the output. The converter handles nested mappings and sequences, flow style, block scalars, comments and the usual scalar types, which covers the configuration files you meet in practice.
Why convert YAML to JSON at all?
- Usually to check structure or to feed a tool. Indentation-based nesting is easy to get subtly wrong, and braces make the actual shape obvious. Beyond that, many APIs and validators accept only JSON, so converting is the quickest route when your source of truth is a YAML file.
Why did my value change type?
- Because YAML infers types from unquoted scalars. The words true, false, yes, no, on and off can all become booleans depending on the specification version; the word null and an empty value become null; and anything that looks numeric becomes a number, which strips leading zeros and trailing zeros after a decimal point. Quote the value if you need it to stay a string.
Are comments preserved?
- No, and they cannot be. JSON has no syntax for comments, so converting YAML to JSON discards them. That is worth remembering before you treat a converted file as a replacement for the original: convert for inspection or for feeding a tool, and keep the commented YAML as the version you edit.
Does it support anchors and aliases?
- Anchors and aliases, the ampersand and asterisk syntax used to reuse a block, are not expanded. They are the part of YAML most likely to surprise a reader, and they appear rarely in the configuration files most people work with. If your document relies on them, resolve them with a full YAML implementation before converting.
Can I convert a multi-document YAML file?
- Files that separate several documents with three hyphens are common in Kubernetes, where one file holds a Deployment and a Service. JSON has no equivalent of the document separator, so convert one document at a time. Splitting on the separator first is the usual approach.
Why does my converted YAML look different from what I wrote?
- Because the output is generated from the parsed structure rather than from your text. Quoting style, flow versus block style, line wrapping and comments are all presentation choices that do not survive a round trip. The data is the same; the formatting is normalised.
Does the key count mean anything?
- It counts the keys in the parsed structure, which makes it a quick check that a conversion did not silently lose part of a document. If you convert a file and the count is smaller than you expect, look for a duplicate key, which is resolved by keeping the last occurrence.
Is it safe to paste a Kubernetes manifest with secret references?
- Yes. Everything is parsed in your browser and nothing is transmitted, stored or logged. Note that a Kubernetes Secret stores its values as Base64, which is encoding rather than encryption, so anyone who has the manifest has the value regardless of which tool they open it in.
Is the YAML I paste sent to a server?
- No. The conversion runs entirely in the page and closing the tab discards whatever you pasted.
// How to Use YAML ⇄ JSON Converter
-
YAML to JSON, or JSON to YAML
Select YAML to JSON or JSON to YAML. The SWAP button moves the current output into the input and flips the direction, which is the fastest way to check that a document survives a round trip.
-
Paste the YAML or the JSON
Put the YAML or JSON into the input box. Conversion happens as you type, and a parse error is reported with the message from the parser rather than being silently ignored.
-
Set the indentation and copy the YAML
Pick the indentation for the output, then copy it with one click. The key count underneath is a quick check that the structure came through complete.
Category Data Formats