Basic object
name: api enabled: true ports: [80, 443]
{
"name": "api",
"enabled": true,
"ports": [80, 443]
}Edit with line numbers and highlighting. Matching brackets are marked at the caret. Press Ctrl/Cmd + Enter to convert.
| YAML value | JSON value | Conversion note |
|---|---|---|
| Mapping | Object | Keys become JSON object property names. |
| Sequence | Array | Nested sequences remain nested arrays. |
| String | String | Multiline scalars become strings with escaped line breaks. |
| Integer or float | Number | Non-finite values become null; large integers can lose JavaScript precision unless quoted. |
| Boolean | Boolean | true and false remain booleans. |
| Null or empty document | null | An empty YAML document produces valid JSON null. |
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.
| Problem | Likely fix |
|---|---|
| Tabs in indentation | Replace indentation tabs with consistent spaces. |
| Inconsistent nesting | Align sibling keys and list markers at the same indentation level. |
| Missing space after a colon | Write key: value, not key:value. |
| Malformed sequence | Put a space after each dash and align list items. |
| Unexpected number or date type | Quote it when it must remain exact text, especially IDs and large integers. |
name: api enabled: true ports: [80, 443]
{
"name": "api",
"enabled": true,
"ports": [80, 443]
}--- kind: Service --- kind: Deployment
[
{ "kind": "Service" },
{ "kind": "Deployment" }
]base: &base retries: 3 one: *base two: *base
{
"base": { "retries": 3 },
"one": { "retries": 3 },
"two": { "retries": 3 }
}No. Parsing and conversion run in your browser. The YAML text and locally opened files are not sent to Starlight Tools.
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.
No. JSON has no comment syntax, so comments, quoting style, whitespace, and other YAML formatting are lost during parsing.
Aliases are expanded into repeated JSON values. A genuinely circular alias is rejected because JSON cannot represent a self-reference.
Yes. Choose JSON array mode to convert every document separated by three hyphens into one JSON array element per YAML document.
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.
No. The data structure can usually be converted back, but comments, anchors, formatting, scalar styles, and sometimes type intent cannot be reconstructed exactly.
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.