yamljson
YAML
JSON

Ready

Everything runs in your browser. Your file is never uploaded, logged or sent anywhere. How can I verify that?

YAML to JSON Converter

Paste YAML, get JSON. It runs entirely in your browser, explains any error in plain English, and tells you exactly what the conversion changed.

What this does that other converters don’t

It tells you what is actually wrong

Most converters answer a broken file with “an error has occurred”. This one names the cause, shows the line, and where the fix is unambiguous it offers a button that applies it.

It lets you choose the YAML version

YAML 1.1 and 1.2 disagree about what NO, onand 22:30 mean. Every other converter picks one and never tells you. This one shows you when your choice changes a value.

It discloses what was lost

Comments, anchors, merge keys and extra documents cannot all survive a trip to JSON. Instead of dropping them quietly, the tool counts them and says so.

A worked example

Here is the same data in both formats. Notice what YAML lets you leave out — braces, most quotes, and every comma — and what it lets you add that JSON cannot express at all: the comment on the first line.

YAML
# scaling for the evening peak
replicas: 3
image: nginx:1.25
resources:
  limits:
    cpu: 500m
    memory: 256Mi
ports:
  - containerPort: 80
  - containerPort: 443
JSON
{
  "replicas": 3,
  "image": "nginx:1.25",
  "resources": {
    "limits": {
      "cpu": "500m",
      "memory": "256Mi"
    }
  },
  "ports": [
    { "containerPort": 80 },
    { "containerPort": 443 }
  ]
}

Three things happened in that conversion that are worth knowing about: the comment disappeared, replicas: 3 stayed a number whilecpu: 500m became a string, and the two-item list became a JSON array. The converter reports the first of those to you rather than letting it pass unnoticed.

When you actually need this

YAML and JSON hold the same shapes of data, so converting between them is almost always about which tool is on the other end rather than about the data itself. The usual reasons people arrive here:

  • An API only speaks JSON. You have a Kubernetes manifest, a docker-compose file or an OpenAPI specification in YAML and need to POST it somewhere, or feed it to a tool that will not read YAML.
  • You want to query it with jq. The tooling for slicing JSON is far richer, so converting first is often quicker than fighting YAML-native equivalents.
  • You are debugging a parse error. Kubernetes, Helm and kubectl all convert YAML to JSON internally, which is why their errors mention JSON. Converting by hand is how you find out what they are actually objecting to.
  • You need to diff two configs. JSON normalises away the many ways YAML can express the same thing — quoting styles, flow versus block, anchors — so two files that look different can be compared properly.
  • You are checking what a value really is. JSON has no ambiguity about types. Converting is the fastest way to confirm whether YAML read 0644 as a number or a string.

YAML gotchas that silently change your data

These are the cases where a converter can hand you valid JSON that means something different from what you wrote. The difference is entirely down to which YAML version the parser follows — and most libraries still default to 1.1.

You wroteYAML 1.1 givesYAML 1.2 givesWhy it matters
country: NOfalse"NO"The Norway problem
on: pushtrue: "push""on": "push"Breaks GitHub Actions
time: 22:301350"22:30"Sexagesimal (base-60)
mode: 0644420644Octal
version: 1.101.11.1Trailing zero lost — quote it

What gets lost converting YAML to JSON

YAML is strictly larger than JSON, so some things have nowhere to go. Here is every case and how this tool handles it.

Comments
Dropped — JSON has no comments. We count them for you.
Anchors and aliases
Expanded in place. Recursive anchors are refused, not looped over.
Merge keys (<<:)
Merged into the parent under YAML 1.1. Under 1.2, which has no merge type, kept as a literal key and flagged.
Multiple documents
Emitted as a JSON array — never silently truncated to the first.
Timestamps
Converted to ISO-8601 strings. JSON has no date type.
Binary (!!binary)
Converted to base64 strings.
Non-string keys
Converted to strings. JSON object keys are always strings.
.inf and .nan
Refused with an explanation — they are not representable in JSON.
Very large integers
Kept exact, with a warning when they exceed JavaScript’s safe range.

Converting YAML to JSON in code

For anything scripted or repeated, do it in code rather than in a browser tab.

Python
import yaml, json

with open("config.yaml") as f:
    data = yaml.safe_load(f)

print(json.dumps(data, indent=2))
Node.js
import { readFileSync } from "node:fs"
import { parse } from "yaml"

const data = parse(readFileSync("config.yaml", "utf8"))
console.log(JSON.stringify(data, null, 2))
Command line (yq)
yq -o=json config.yaml

# every document in a multi-document file
yq -o=json -N '[.]' config.yaml
Go
import "sigs.k8s.io/yaml"

jsonBytes, err := yaml.YAMLToJSON(yamlBytes)

One caution that applies to all of them: Python’s PyYAML and several other libraries still implement YAML 1.1, so NO andon will become booleans there even though this page shows them as strings under 1.2.

Common “error converting YAML to JSON” messages

Kubernetes, Helm and kubectl parse YAML by converting it to JSON internally, which is why their error messages mention JSON even when you never asked for any. Five causes account for nearly all of them.

did not find expected key

Usually a list whose items are missing their leading "- ". The parser blames the second repeated key, so the real problem is a few lines above where it points.

mapping values are not allowed in this context

A value contains an unquoted colon followed by a space, so YAML reads it as the start of a new key. Wrap the value in quotes.

did not find expected '-' indicator

A sequence and a mapping are mixed at the same indentation level.

invalid map key: map[interface {}]interface {}

Helm or Go template syntax in a file being parsed as plain YAML. Render the template first.

invalid leading UTF-8 octet

A byte-order mark or another invisible character, almost always added by a Windows editor or by copying from a web page.

Paste the file into the converter above and it will tell you which of these it is, and on which line.

Frequently asked questions

How do I convert YAML to JSON in Python?

Load the YAML with PyYAML and dump it as JSON: import yaml, json — then data = yaml.safe_load(open("config.yaml")) followed by print(json.dumps(data, indent=2)). Always use safe_load rather than load, which can execute arbitrary Python. One warning: PyYAML implements YAML 1.1, so NO, yes, on and off become booleans there even though YAML 1.2 keeps them as strings. Use ruamel.yaml if you need 1.2 behaviour.

How do I convert YAML to JSON in Linux or from the command line?

The usual tool is yq. With Mike Farah’s Go version, run yq -o=json config.yaml. With the Python wrapper of the same name by Andrey Kislyuk, the command is just yq . config.yaml, because it outputs JSON by default. The two are different programs with different syntax, which is the most common source of confusion — check with yq --version first. Python one-liners also work: python3 -c "import yaml,json,sys; print(json.dumps(yaml.safe_load(sys.stdin)))" < config.yaml.

How do I convert YAML to JSON in VS Code (vscode)?

Visual Studio Code has no built-in YAML to JSON command. Two things work reliably. Install a vscode extension that adds a conversion command to the palette, or open the integrated terminal and run yq -o=json config.yaml, which needs nothing installed in the editor itself. If you would rather not add an extension, pasting into the converter on this page is quicker than either.

How do I convert YAML to JSON in IntelliJ?

IntelliJ IDEA does not ship a one-click YAML to JSON action in the base IDE. Plugins from the JetBrains Marketplace add one, and the built-in terminal can run yq -o=json config.yaml without installing anything. For a quick one-off, pasting into this page avoids restarting the IDE for a plugin you will use once.

How do I convert YAML to JSON in Java?

Use Jackson with the YAML data format module. Read the YAML with an ObjectMapper backed by YAMLFactory, then write it out with a plain ObjectMapper: new ObjectMapper(new YAMLFactory()).readValue(file, Object.class) gives you the object, and new ObjectMapper().writeValueAsString(obj) gives you the JSON. Add the jackson-dataformat-yaml dependency alongside jackson-databind.

How do I convert YAML to JSON in JavaScript or Node.js?

Install the yaml package and parse, then stringify: import { parse } from "yaml", then JSON.stringify(parse(text), null, 2). The older js-yaml package works the same way with load(). Prefer yaml if you care about YAML 1.2 semantics or need precise error positions — js-yaml reports only the first error and cannot switch YAML versions. This site uses the yaml package for exactly those reasons.

How do I convert YAML to JSON online without installing anything?

Paste your YAML into the converter at the top of this page. It works on any operating system, needs no install, no sign-up and no extension, and the conversion happens in your browser rather than on a server. It handles multi-document files, anchors and aliases, and explains parse errors with the exact line rather than just refusing.

Is there a YAML to JSON example I can look at?

Yes — the worked example on this page shows the same Kubernetes configuration in both formats side by side, and the converter is pre-loaded with a real Deployment manifest so you can see a complete conversion before typing anything. The example also points out the three things that change in that conversion: the comment disappears, replicas stays a number while cpu becomes a string, and the list becomes a JSON array.

Can I convert YAML to a JSON Schema?

That is a different thing, and worth separating. Converting YAML to JSON gives you the same data in another format. A JSON Schema is a separate document that describes what shape valid data must take — types, required fields, allowed values. Converting will not produce one; you need a schema generator or you write it by hand. If your YAML already contains a JSON Schema written in YAML, then converting it here does give you that schema as JSON.

Why did my value NO turn into false?

That is the Norway problem. Under YAML 1.1, the words yes, no, on, off, y and n are booleans, so a country list containing NO silently becomes false. YAML 1.2 fixed this — only true and false are booleans. This converter defaults to 1.2 and warns you whenever the version you picked changes a value type.

What does the error "error converting YAML to JSON" mean?

That message comes from Kubernetes, Helm or kubectl, which parse YAML by converting it to JSON internally. It almost always means one of five things: a list whose items are missing their leading dash, a value containing an unquoted colon, a tab used for indentation, an invisible character such as a byte-order mark, or template syntax in a plain YAML file. Paste the file above and the tool will tell you which one it is and on which line.

What happens to comments, anchors and multiple documents?

Comments cannot survive, because JSON has no comment syntax — the tool counts them and tells you how many were dropped. Anchors and aliases are expanded in place, and merge keys are resolved, since JSON cannot reference a value defined elsewhere. A multi-document file separated by --- becomes a JSON array with one entry per document, so nothing is silently lost the way many converters lose everything after the first document.

Is my data uploaded anywhere?

No. The conversion runs entirely in your browser using JavaScript downloaded with the page. Nothing is sent to a server, nothing is logged, and there is no account. You can confirm it yourself: open DevTools, switch to the Network tab, and convert something — you will see no requests. A Content Security Policy on the site blocks outbound requests entirely, so this is enforced by your browser rather than merely promised.