YAML to JSON

Convert YAML config into formatted JSON. Free, in your browser.

Converts YAML to formatted JSON in your browser.

Free to use — premium coming soon

FREE
  • Formatted JSON
  • Error messages
  • 100% private
PREMIUM
  • Remove ads
  • Schema validation

About the YAML to JSON

YAML to JSON converts a YAML document into equivalent JSON. YAML is the format people write by hand for configuration files, GitHub Actions workflows, Kubernetes manifests, Docker Compose, and CI pipelines, because it is readable and lets you add comments. JSON is the format machines exchange over the wire: almost every REST API, JavaScript runtime, and validation library speaks it natively. This tool bridges the two. Paste your YAML, and it parses the indentation-based structure into nested objects and arrays, then serializes that structure as standard JSON you can drop into an API request, a config loader, or a test fixture.

Reach for this converter whenever something downstream expects JSON but your source of truth is YAML. Common cases: posting a Kubernetes manifest to an API that only accepts JSON bodies, feeding a YAML config into JavaScript code where JSON.parse is built in but a YAML parser is an extra dependency, generating JSON fixtures from human-friendly YAML, or simply diffing two formats. It is also a debugging trick. Because YAML infers types from unquoted text, converting to JSON shows you exactly what the parser saw, so you can spot a value that became a number, a boolean, or null when you meant a string.

Under the hood the tool reads YAML's structure from indentation and key markers, builds an in-memory tree of mappings, sequences, and scalars, then writes that tree back out using JSON syntax with braces, brackets, and double-quoted keys. Scalars are resolved to JSON types: unquoted 42 becomes a number, true becomes a boolean, an empty value or null becomes JSON null, and quoted text stays a string. Note that JSON has no equivalent for YAML comments or anchors, so those are dropped or expanded during conversion. Indentation must use spaces, never tabs, or parsing will fail.

Conversion runs entirely in your browser. Your YAML is never uploaded to a server, which matters because config files often hold API keys, connection strings, or internal hostnames. One accuracy caveat worth knowing: YAML's automatic typing can surprise you. In older YAML 1.1 parsers the strings yes, on, and the country code NO are read as booleans, and a value like 1.10 collapses to 1.1. The resulting JSON faithfully reflects whatever the parser decided, so if a field looks wrong, quote it in your YAML and convert again.

Frequently asked questions

Is every JSON document also valid YAML?

Yes, as of YAML 1.2 (released 2009) the spec is designed to be a strict superset of JSON, so any valid JSON is also valid YAML. The reverse is not true: YAML has features like comments, anchors, and multi-document files that have no JSON equivalent and are lost or rejected when converting to JSON.

Why does my conversion fail or change values unexpectedly?

The most common cause is indentation: YAML forbids tabs, so a stray tab character produces a parse error even though the file looks fine. Unexpected values usually come from YAML's automatic typing, where unquoted text like yes, no, or 08080 is read as a boolean or number. Wrap such values in quotes to keep them as strings.

What happens to comments and anchors when I convert to JSON?

JSON does not support comments, so any # comments in your YAML are discarded. YAML anchors and aliases (& and *) are expanded into their referenced values, so the JSON output contains the full duplicated data rather than a reference.

What is the Norway problem in YAML?

It is a famous typing pitfall where the string NO (Norway's country code) is parsed as the boolean false in YAML 1.1 parsers, so a list like [FI, NO, SE] becomes ["FI", false, "SE"]. YAML 1.2 removed most of these implicit boolean aliases, but many tools still run 1.1 parsers, so quoting string values is the safe habit.

Does my data get uploaded anywhere?

No. The conversion happens locally in your browser using JavaScript, so your YAML is never sent to a server. That keeps secrets such as API keys or database passwords that often live in config files private to your machine.

From our blog

XML to JSON: A Practical Guide to the Mapping That Trips People Up

By the Super Simple Digital Tools Team · Updated June 2026

XML and JSON both describe structured data, but they were designed for different worlds. XML grew up around documents: it has namespaces, schemas, mixed content (text and tags woven together), comments, and a strict notion of element order. JSON grew up around data interchange for the web: objects, arrays, strings, numbers, booleans, and null, with no attributes, comments, or namespaces. Converting from one to the other is less a translation and more a projection. You are taking a richer document model and flattening it into a leaner data model, and understanding what gets lost in that projection is the key to using the result confidently.

The first thing every converter must solve is attributes. In XML, <product sku="A1">Widget</product> carries both an attribute and text. JSON has only properties, so the attribute has to become a property too. The common solution is to prefix attribute keys so they cannot clash with child element names, most often with @, and to park the element's own text under a separate key. The BadgerFish convention formalises this with @ for attributes and $ for text content, which is verbose but loses very little. Simpler conventions read better but may discard the distinction between an attribute and a child element.

The second classic problem is arrays. XML does not have an array type, it just lets you repeat a tag. So <tags><tag>a</tag><tag>b</tag></tags> clearly should become a list, but <tags><tag>a</tag></tags> is ambiguous: is tag a single value or a list of one? Converters guess, and different tools guess differently. This is the single most common cause of bugs after conversion, because code that expects an array gets an object, or vice versa. The defensive fix is to coerce the field to an array in your own code before iterating, regardless of how the converter rendered it.

Then there is everything JSON simply cannot hold. Comments and processing instructions vanish. The XML declaration is dropped. Namespaces are usually reduced to local names, so the prefix information is gone. Mixed content, where text and child elements interleave inside one element, is awkward to model and is often serialised as a single string. None of this means the conversion is wrong, it means the conversion is lossy by design. If you need a perfect round trip back to the original XML byte-for-byte, JSON is the wrong intermediate format and you should keep the XML.

In practice the workflow is straightforward: get your XML from the SOAP response, RSS feed, or config file, paste it in, and read the JSON output. Then inspect the structure before wiring it into code, paying special attention to which fields became arrays and how attributes were prefixed. Because the conversion runs in your browser, you can do this with private payloads without sending them anywhere. Once you know the shape, parsing the JSON in JavaScript, Python, or any other language is trivial compared with walking an XML tree by hand, which is the whole point of converting in the first place.

  • Before coding against the output, scan for fields that became arrays versus single objects, and normalise repeated elements to arrays yourself so a one-item case does not break your loop.
  • Expect attributes to appear with a prefix such as @ in the JSON; reference them by that exact key rather than assuming they merged into the element.
  • If you rely on comments, the XML declaration, or strict element order, keep the original XML, since conversion to JSON discards all three.
  • For SOAP or namespaced documents, remember keys are usually shortened to local names (soap:Body becomes Body), so target the simplified key in your code.

Read the full guide →

Tool by the Super Simple Digital Tools Team. Reviewed by our editorial team. Free to use, no signup required.

Related tools