Convert YAML to JSON

Paste any YAML document and get the matching JSON representation. The YAML to JSON converter parses block and flow style input, resolves typed scalars (numbers, booleans, null, dates as strings), and emits a pretty-printed JSON tree. Mappings become objects, sequences become arrays, plain scalars become the right primitive type. The transform runs in your browser; nothing uploads.

Input
Line 1:1 LF cloud_done Saved locally
Result YAML to JSON
0 lines 0 chars

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

  1. 1Paste your YAML document into the input panel on the left.
  2. 2The JSON result appears in the output panel on the right as you type.
  3. 3Click Copy in the output header to copy the JSON.
  4. 4Click Download to save the result as a .json file.
  5. 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 FOpen the find & replace panel inside the input Plus
Ctrl ZUndo the last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor Plus
EscClose find & replace, or exit fullscreen
Ctrl KOpen the command palette to jump to any tool Plus
Ctrl SSave current workflow draft Plus
Ctrl PRun 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.

Input
site: textresult
tags:
  - text
  - tools
public: true
owner: null
Output
{
  "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?
Yes. An &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?
YAML 1.2 core schema treats ISO 8601 dates as plain strings, and so does the converter. The value 2024-05-04 becomes the JSON string "2024-05-04". If you need a Unix timestamp instead, run a downstream transform.
What about comments?
YAML comments are stripped during parsing because JSON has no comment syntax. If you need to keep the comment text, move it into a key like _comment in the YAML before converting.
Is the YAML sent anywhere?
No. The parse and emit run entirely in your browser via JavaScript. Nothing is uploaded, nothing is logged, no record of your text exists on our servers.
What if the YAML has multiple documents?
Multi-document streams use --- 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.