LocalToolkit
HomeData Converters › YAML to JSON Converter

YAML to JSON Converter

For Kubernetes manifests, CI configs and Ansible playbooks you need in JSON form.

🔒 Runs in your browser. Nothing is uploaded — verify it in the network panel, or disconnect and try again.

The subset that covers real config files

The YAML specification is enormous, and almost none of it appears in ordinary configuration. What actually shows up — and what this converter handles — is a small, well-defined core:

Where a small parser meets its limits

FeatureStatusWhat to do instead
Block scalars | and >Supported
CommentsStrippedJSON cannot carry comments
Anchors and aliases &/*Not expandedResolve them before converting, or use a full parser
Merge keys <<Not mergedExpand manually
Custom tags !!strNot appliedRemove them or use a schema-aware parser
Multiple documents in one fileFirst documentSplit on --- first

Comments disappear, and that is the point

JSON has no comment syntax, so converting YAML to JSON always discards them. That is usually harmless for a machine that just needs the data — but it makes the conversion a one-way operation. If the file is edited by people, keep the YAML as the source of truth and convert in the other direction for the tools that require JSON. Round-tripping JSON → YAML → JSON preserves values; YAML → JSON → YAML does not preserve comments.

Why the colon rules bite

A colon is a key separator only when followed by a space or end of line. That single rule explains two common failures: a URL like http://example.com is a fine plain scalar because the colon is followed by a slash, while a value like time: 12:30 breaks because 12:30 looks like it begins a nested mapping. Quote the value and the ambiguity disappears. The same rule applies to a leading -, which becomes a sequence indicator unless the value is quoted.

Parsing untrusted YAML

If the YAML arrives from an untrusted source, do not parse it with a full-featured loader. Aliases expand, and nested aliases expand exponentially — a file of a few kilobytes can be made to consume gigabytes of memory. Any production pipeline accepting untrusted YAML should disable alias expansion and cap document size, and a strict subset parser like this one sidesteps the problem entirely.

How to use it

  1. Paste the YAML document.
  2. Convert and inspect the resulting JSON structure.
  3. Check the value types — a no may have become false depending on how it was quoted in the source.
  4. Validate against your schema before use.

Worth knowing

  • A colon separates a key only when followed by whitespace or end of line.
  • Tabs are never valid indentation in YAML.
  • | preserves line breaks in a block scalar; > folds them into spaces.
  • Alias expansion can be used to exhaust memory from a tiny document.

Limitations

  • Anchors, aliases, merge keys and custom tags are not expanded.
  • Only the first document in a multi-document file is converted.
  • Comments are discarded, so this conversion is not reversible.
  • YAML 1.1 implicit typing may differ from what your production parser does.

Frequently asked questions

Why did `no` become `false`?
Because YAML 1.1 treats unquoted no as a boolean. It is the Norway problem. Quote such values in the source — "no" — to keep them as strings.
Can I keep the comments?
No. JSON has no comment syntax, so any YAML-to-JSON conversion necessarily drops them. Keep the YAML as the source of truth and convert outward.
How do I convert a Kubernetes manifest?
Paste it directly. Manifests use plain block mappings and sequences, which convert cleanly. If the file contains multiple documents separated by ---, convert them one at a time.
Is it safe to parse YAML from a user?
Not with a full loader that expands aliases — that enables the billion laughs attack. Use a safe loader with alias expansion disabled, or parse a restricted subset as this tool does.
Related tools
JSON to YAML ConverterJSON Formatter & ValidatorXML to JSON ConverterCSV to JSON ConverterJSON MinifierJSON to CSV Converter
Keep reading
How browser-only processing worksAll Data Converters toolsEvery tool on the site