YAML to JSON, plain and predictable
YAML to JSON conversion parses YAML 1.2 source with the standard core schema and emits a matching JSON document. Block mappings map to JSON objects. Block and flow sequences map to JSON arrays. Plain scalars resolve as the YAML core schema dictates: true, false, null, integers, floats, and otherwise strings. Quoted scalars stay strings, even when their text looks like a number. The output is pretty-printed with two-space indentation so it stays readable.
Anchors and aliases are resolved at parse time, so a referenced node appears in full at every alias position in the JSON output. Multi-line plain, folded (>) and literal (|) block scalars all collapse to the right string value with newlines preserved or folded as YAML defines. Comments are stripped, since JSON has no comment syntax. Document separators (---) start a new top-level value; if multiple documents are present, the converter emits them as a JSON array of documents.
If the YAML is malformed, the parser message is shown in the output panel. For the inverse direction, see JSON to YAML. If your input is a CSV file rather than YAML, see CSV to JSON.
How to use convert yaml to json
- 1Paste your YAML document into the input panel on the left.
- 2The JSON result appears in the output panel on the right as you type.
- 3Click Copy in the output header to copy the JSON.
- 4Click Download to save the result as a
.jsonfile. - 5If the input is invalid YAML, fix the parser message shown in the output panel.
Keyboard shortcuts
Drive TextResult without touching the mouse.
| Shortcut | Action |
|---|---|
| Ctrl F | Open the find & replace panel inside the input Plus |
| Ctrl Z | Undo the last input change |
| Ctrl Shift Z | Redo |
| Ctrl Shift Enter | Toggle fullscreen focus on the editor Plus |
| Esc | Close find & replace, or exit fullscreen |
| Ctrl K | Open the command palette to jump to any tool Plus |
| Ctrl S | Save current workflow draft Plus |
| Ctrl P | Run a saved workflow Plus |
What this tool actually does
YAML 1.2 core schema parsing
The parser follows the YAML 1.2 core schema. Plain scalars resolve to true/false, null, integers, floats, or strings via the standard regex set. Quoted scalars always stay strings. Tags such as !!str, !!int, !!float, !!bool and !!null are honoured.
Anchors and aliases resolved inline
An anchor node defined with &name and aliased with *name is expanded at every alias position, so the resulting JSON contains the full subtree at each spot. Cyclic aliases are rejected since JSON cannot represent them.
Block, folded and literal scalars
Multi-line plain text, folded scalars introduced with >, and literal scalars introduced with | all collapse to the right JSON string. Folded scalars convert internal newlines to spaces; literal scalars keep newlines verbatim. Trailing newline handling follows the chomp indicator (-, +, default).
Pretty-printed JSON output
Output uses two-space indentation. Object keys are emitted in the order the YAML parser produced them. Strings are JSON-escaped, so embedded quotes, backslashes and control characters become \", \\ and the standard short escapes.
Runs entirely in your browser
No upload, no server-side processing, no log of what you pasted. The parse and emit run on every keystroke. Errors render inline so you can fix the source without leaving the page.
Worked example
Mapping keys become object keys, the block sequence becomes an array, true and null resolve as JSON primitives.
site: textresult tags: - text - tools public: true owner: null
{
"site": "textresult",
"tags": [
"text",
"tools"
],
"public": true,
"owner": null
}
Settings reference
| Behaviour | Effect on output |
|---|---|
| Schema | YAML 1.2 core schema. Plain scalars resolve to bool, null, int, float or string by the standard regex set. |
| Indentation | Two-space JSON indent. Object keys preserve YAML order. |
| Anchors and aliases | Resolved inline. Cyclic references are rejected. |
Folded scalars (>) |
Internal newlines fold to spaces. Trailing newline follows the chomp indicator. |
Literal scalars (|) |
Internal newlines are preserved verbatim. |
| Tags | !!str, !!int, !!float, !!bool, !!null override the implicit type resolution. |
| Multiple documents | Multi-document streams (separated by ---) emit as a JSON array of documents. |
| Invalid YAML | Parser message is shown in the output panel; no partial JSON is emitted. |
FAQ
Does it support YAML anchors and aliases?
&anchor node and any *alias reference resolve to the same value in the JSON output. The aliased subtree is duplicated inline, since JSON has no alias syntax. Cyclic aliases are rejected because JSON cannot represent them.How are dates handled?
2024-05-04 becomes the JSON string "2024-05-04". If you need a Unix timestamp instead, run a downstream transform.What about comments?
_comment in the YAML before converting.Is the YAML sent anywhere?
What if the YAML has multiple documents?
--- as a separator. The converter emits them as a JSON array of documents, in the same order they appeared in the source. Single-document YAML files emit a single JSON value at the top level.