Skip to content
Browser tool Runs locally

YAML to JSON Converter

Convert YAML into formatted JSON. Runs locally in your browser.

YAML input
JSON output
JSON output will appear here.

What is YAML to JSON conversion?

YAML and JSON represent the same core data model - mappings, sequences, strings, numbers, booleans, and null. Converting to JSON keeps the values and structure intact while dropping YAML-only features like comments, anchors, and multiple documents in one file, since JSON has no equivalent for those.

How to convert YAML to JSON

  1. Paste YAML in the input panel.
  2. Click Convert to JSON.
  3. Copy or download as yaml-to-json.json.

Common use cases

Converting YAML to JSON is common when a config file written for humans - a Kubernetes manifest, a Docker Compose file, a CI pipeline definition, an application settings file - needs to be consumed by code or an API that expects strict JSON. It's also useful for feeding YAML config into JSON Schema validators, JavaScript objects, or any tool in a pipeline that doesn't have a native YAML parser.

YAML indentation and typing

YAML uses indentation, not brackets, to express nesting, so the structure of the input matters down to the space. Typing is also looser than JSON's: unquoted values are inferred as numbers, booleans, null, or strings based on their shape, which is convenient to write but means a value like version: 1.20 can quietly become a different type than a value like version: "1.20". The conversion follows the YAML 1.2 JSON schema for this inference to keep results predictable.

Duplicate keys

YAML technically allows a mapping to repeat the same key more than once, even though most style guides discourage it. When that happens here, the later value overwrites the earlier one, matching common parser behavior - the first value is dropped rather than kept or merged, so it's worth checking generated or hand-edited YAML for accidental repeats before converting.

Multi-document YAML isn't supported

A single YAML file can contain multiple documents separated by ---, but JSON has no way to represent more than one top-level document in one file. Pasting multi-document YAML here is rejected with a clear message rather than silently converting only the first document or merging them - split the file and convert each document separately instead.

A practical example

YAML like name: web on one line, port: 8080 on the next, and debug: false on a third converts to {"name":"web","port":8080,"debug":false} - the indentation-based structure becomes explicit braces and commas, and each value keeps its inferred type.

Common mistakes

  • Mixing tabs and spaces - YAML forbids tabs for indentation, and mixed whitespace is one of the most common parse failures.
  • Expecting yes/no/on/off to become booleans - under the YAML 1.2 JSON schema this tool uses, those stay strings, unlike some looser YAML parsers.
  • Leaving in --- document separators - a file with more than one document needs to be split before converting, since JSON can't represent multiple documents.
  • Assuming comments carry over - any # comments in the YAML are dropped, since JSON has no comment syntax to hold them.

Frequently asked questions

How are YAML types handled?
Parsing follows the YAML 1.2 JSON schema, so values like yes, no, on, and off are treated as plain strings rather than booleans, and unquoted numbers and true/false/null convert to their JSON equivalents. This avoids the looser type-guessing some older YAML parsers use.
Are comments preserved?
No. Standard JSON has no comment syntax, so any # comments in the YAML input are discarded during conversion - the resulting JSON only reflects the data, not the annotations around it.
How are duplicate keys handled?
When the same key appears twice in a YAML mapping, the later value overwrites the earlier one - last-wins - matching how most YAML parsers resolve duplicates. The earlier value is silently dropped, so it's worth double-checking input that wasn't hand-written.
Can this tool convert multi-document YAML files that use --- separators?
No - a file with multiple --- separated documents is rejected with a clear message rather than guessed at, since JSON has no equivalent for "multiple documents in one file." Convert one document at a time by removing the separators and extra documents first.
Why does my converted JSON have quotes around values that weren't quoted in the YAML?
JSON requires double quotes around every string and key, while YAML allows plain, unquoted text for the same values. The conversion adds the quoting JSON needs - it doesn't mean anything changed about the underlying value.

Related tools