FormatterHQ

YAML Parser

See what your code will get from a YAML file: every mapping, list and scalar after parsing, with types resolved, shown as JSON and as a tree.

Input YAML
Output JSON
Ready.

How to use the YAML Parser

  1. Paste the YAML into the input editor, or load it with Upload file, Load URL or Sample.
  2. Click Parse.
  3. Check the status bar for Valid YAML ✓ or an error with line and column.
  4. Inspect the result in the Tree tab or as JSON in Code, then copy or download it.

What a YAML parser returns

A YAML parser turns text into plain data structures: mappings become objects (dictionaries), sequences become arrays (lists) and scalars become strings, numbers, booleans or null. This online YAML parser shows you that result directly. It is the quickest way to answer "what will yaml.safe_load or YAML.parse give me for this file?" without writing a script.

Example: from YAML text to data

defaults: &defaults
  adapter: postgres
  pool: 5
development:
  database: app_dev
  settings: *defaults
tags:
  - api
  - "2024"

Parsing produces:

{
  "defaults": { "adapter": "postgres", "pool": 5 },
  "development": {
    "database": "app_dev",
    "settings": { "adapter": "postgres", "pool": 5 }
  },
  "tags": ["api", "2024"]
}

(The Code tab indents this fully; it is condensed here.) The alias *defaults is replaced by a copy of the anchored mapping, pool is a number and the quoted "2024" stays a string.

How scalars are resolved

YAMLParsed as
true / falseboolean
yes / no / onstring (YAML 1.2 rules)
~, null or an empty valuenull
0x1F, 0o14, 1e3numbers 31, 12, 1000
007number 7
2024-05-01string "2024-05-01" (no date object is created)
!!str 42string "42" (explicit tag)

These rules explain most "it worked on my machine" YAML bugs. A postal code written as 02134 arrives in your program as the integer 2134, and a list of country codes containing NO is read as the string "NO" here but as the boolean false by a YAML 1.1 library. When the parsed output differs from what you meant, add quotes in the source file rather than patching the value later in code.

Things that do not survive parsing

  • Comments are not part of the data model, so they never appear in the parsed output.
  • Merge keys (<<: *base) are not merged by this parser; the aliased mapping shows up under a literal << key.
  • Special floats like .inf and .nan parse correctly but are displayed as null, because JSON cannot represent them.
  • Key order is kept as written, although YAML itself treats mappings as unordered.

The same parse in your own code

Once the output looks right, you can expect the same structure from the YAML library in your language. Typical calls are:

  • JavaScript (js-yaml): yaml.load(text), or yaml.loadAll(text) for several documents.
  • Python (PyYAML): yaml.safe_load(f) and yaml.safe_load_all(f).
  • Go (gopkg.in/yaml.v3): yaml.Unmarshal(data, &out).
  • Ruby (Psych): YAML.safe_load(text).

Prefer the "safe" loaders in production. They build only plain data types and refuse tags that would create arbitrary objects, which matters whenever the YAML comes from a user or another system. Differences between libraries mostly show up in the edge cases from the table above, so test values such as leading zeros, dates and yes/no with the library you actually deploy.

Multiple documents

A stream such as a combined Kubernetes manifest contains several documents separated by ---. The parser returns them as an array, one element per document, so you can check each resource separately in the tree.

Related tools

To convert the parsed data into a file you can use elsewhere, try the YAML to JSON converter. For a friendlier read-only exploration, open the YAML viewer. JSON input? The JSON parser works the same way.

Privacy

Parsing happens in your browser with JavaScript; your YAML is not uploaded. Only Load URL and Save & Share involve our server.

YAML parser in Python

The standard library has no YAML module, so the usual YAML parser in Python is PyYAML. Call yaml.safe_load() on a string or an open file; plain yaml.load() fails without an explicit Loader argument. What catches people out is typing. PyYAML follows YAML 1.1 rules, so an unquoted yes becomes True and 2024-05-01 becomes a datetime.date object rather than a string.

# pip install pyyaml
import yaml

text = """
name: demo
port: 8080
debug: yes
released: 2024-05-01
tags: [api, "2024"]
"""

data = yaml.safe_load(text)
print(data)
print(type(data["debug"]).__name__, type(data["released"]).__name__)

Paste the same text into the parser above to compare: it applies YAML 1.2 rules and keeps both of those values as strings, so quote them in the file if every reader must agree.

Frequently asked questions

Is this parser compatible with PyYAML or SnakeYAML?
It follows YAML 1.2, while PyYAML implements YAML 1.1. Most files parse identically, but values like yes, no, on, off and numbers with leading zeros can be typed differently. Quote such values to get the same result everywhere.
Does the parser execute YAML tags like !!python/object?
No. Only standard, safe types are constructed. Language-specific tags are not executed, and unknown tags produce an error.
Why are my comments missing from the output?
Comments are ignored by every YAML parser because they are not data. Use the YAML formatter if you need to keep comments while tidying a file.
How are anchors and aliases handled?
Each alias is replaced by the full value of its anchor, so the output shows the expanded data. Merge keys written as

Last updated October 3, 2026

Related tools

JSON Parser Parse JSON online: errors with line and column, the parsed values with their types, and the pitfalls of big integers and duplicate keys. XML Parser Parse XML online and inspect the resulting object tree with elements, attributes and text nodes clearly separated. Base64 to YAML Decode a Base64 string back to YAML with syntax highlighting. CSV to YAML Converter Convert CSV to YAML online for free. Clean, readable YAML with configurable indentation. .env to YAML Converter Convert .env files to YAML for Docker Compose, Kubernetes or CI configs, optionally nesting keys on a separator. HTML Table to YAML Converter Convert HTML to YAML online for free. Clean, readable YAML with configurable indentation. YAML Pretty Print Pretty print YAML online and see the yq, PyYAML and js-yaml settings that give the same block style, key order and indent. YAML Validator Validate YAML syntax online. Catch bad indentation, duplicate keys and invalid values with exact line and column numbers. YAML Viewer View YAML as an interactive tree and table. Explore nested maps and lists and see how every value is parsed. YAML Beautifier Clean up messy Kubernetes, Compose and CI YAML: consistent indentation and spacing, with comments and anchors kept as written. YAML Editor Edit YAML online with syntax highlighting, live validation and a tree preview. Format and download your file when done. YAML Formatter Format YAML online with consistent indentation while keeping comments. Validate syntax and see the exact line of any error.