Free Online YAML to JSON Converter

Paste YAML or open a .yaml/.yml file to validate it and convert it to formatted or minified JSON. Processing stays in your browser.

YAML input

Line 1, column 1

Edit with line numbers and highlighting. Matching brackets are marked at the caret. Press Ctrl/Cmd + Enter to convert.

Output settings
JSON formatting
YAML stream output

Single document mode requires one YAML document. JSON array mode converts every ----separated document into an array item.

JSON output

Read-only result
0 characters · 0 linesWaiting for YAML

Advertisement

How to convert YAML to JSON

  1. Paste YAML, open a local file, or choose a sample.
  2. Choose single-document or JSON-array output and the desired formatting.
  3. Review live validation or select Convert, then copy or download valid JSON.

Real DevOps uses

  • Inspect Kubernetes resources as the JSON shape accepted by an API.
  • Transform Docker Compose, GitHub Actions, or OpenAPI data for scripts.
  • Validate configuration indentation and expand aliases before debugging.

How YAML types map to JSON

YAML valueJSON valueConversion note
MappingObjectKeys become JSON object property names.
SequenceArrayNested sequences remain nested arrays.
StringStringMultiline scalars become strings with escaped line breaks.
Integer or floatNumberNon-finite values become null; large integers can lose JavaScript precision unless quoted.
BooleanBooleantrue and false remain booleans.
Null or empty documentnullAn empty YAML document produces valid JSON null.

What conversion does not preserve

Comments, whitespace, quoting choices, block styles, tags, and anchor names are presentation details that JSON cannot retain. Aliases are expanded. Do not rely on object key order. Duplicate keys are rejected rather than silently overwritten. A truly circular alias is rejected because JSON has no reference type.

Compatibility: this page uses js-yaml 4.1.0 with its default YAML 1.2-compatible schema. One YAML document becomes one JSON root. In JSON array mode, each document in a ----separated stream becomes one array element.

Common YAML errors and fixes

ProblemLikely fix
Tabs in indentationReplace indentation tabs with consistent spaces.
Inconsistent nestingAlign sibling keys and list markers at the same indentation level.
Missing space after a colonWrite key: value, not key:value.
Malformed sequencePut a space after each dash and align list items.
Unexpected number or date typeQuote it when it must remain exact text, especially IDs and large integers.

YAML to JSON examples

Basic object

name: api
enabled: true
ports: [80, 443]
{
  "name": "api",
  "enabled": true,
  "ports": [80, 443]
}

Kubernetes stream

---
kind: Service
---
kind: Deployment
[
  { "kind": "Service" },
  { "kind": "Deployment" }
]

Anchor and aliases

base: &base
  retries: 3
one: *base
two: *base
{
  "base": { "retries": 3 },
  "one": { "retries": 3 },
  "two": { "retries": 3 }
}

YAML to JSON converter FAQs

Is pasted YAML uploaded?

No. Parsing and conversion run in your browser. The YAML text and locally opened files are not sent to Starlight Tools.

Does this converter support YAML 1.2?

It uses js-yaml 4.1.0 and its default YAML 1.2-compatible schema. It does not implement every optional YAML type or preserve presentation details.

Are YAML comments preserved in JSON?

No. JSON has no comment syntax, so comments, quoting style, whitespace, and other YAML formatting are lost during parsing.

How are YAML anchors and aliases handled?

Aliases are expanded into repeated JSON values. A genuinely circular alias is rejected because JSON cannot represent a self-reference.

Can Kubernetes multi-document YAML files be converted?

Yes. Choose JSON array mode to convert every document separated by three hyphens into one JSON array element per YAML document.

Why did a YAML number or date change type?

The parser resolves plain scalars according to its schema. Quote values such as identifiers, dates, or large integers when their exact text and precision must be preserved.

Can JSON be converted back to the original YAML without loss?

No. The data structure can usually be converted back, but comments, anchors, formatting, scalar styles, and sometimes type intent cannot be reconstructed exactly.

How are invalid YAML and duplicate keys handled?

Invalid syntax and duplicate mapping keys stop conversion. The editor keeps the source and reports the parser line, column, excerpt, and a likely fix when available.

Explore more tools