Topic

YAML without structural or type errors

Understand YAML indentation, lists, quoting, and scalars before converting files or using them as configuration.

YAML can express mappings, sequences, and values with little visual noise, but that convenience means indentation and scalar style carry meaning. This path starts with visible structure and ends with the differences that can appear when a configuration is converted or shared.

What to inspect first

Check that sibling entries start in the same column, that each dash belongs to the intended sequence, and that text-like values do not resolve as booleans or numbers. Quote a value when you need to fix its type or stop characters such as # and : from being read as syntax.

A safe sequence

  1. Review spaces and indentation levels.
  2. Distinguish mappings, sequences, and scalars.
  3. Decide whether a string needs single quotes, double quotes, or block style.
  4. Convert to JSON to inspect the resolved structure.
  5. Compare keys, arrays, and types with the application’s expected model.

The converter supports the documented YAML 1.2 subset. A document may be valid for another processor while using features that cannot map directly to JSON, including aliases and custom tags. This path explains those limits before a silent conversion changes the result.

Tools

Tools for this topic

Guides

Guides in a recommended order

  1. YAML indentation: spaces, tabs, and common errorsLearn how YAML indentation defines structure, why tabs cannot indent a block, and how to find a value at the wrong level.
  2. How to write YAML lists and objects at the correct levelLearn to combine YAML sequences and mappings, align list markers, and verify the equivalent JSON structure.
  3. Quotes in YAML: single, double, or unquoted stringsLearn when to use single quotes, double quotes, or plain scalars in YAML and how they affect escapes, comments, and types.
  4. YAML booleans: why yes, no, on, and off depend on the versionPrevent words such as yes, no, on, and off from changing between strings and booleans across YAML parsers and versions.
  5. YAML multiline strings: the difference between | and >Understand literal and folded YAML block scalars, chomping indicators, and how to preserve or join line breaks.
  6. YAML anchors, aliases, and merge keysUnderstand YAML node reuse, why JSON does not retain references, and what to verify before converting merged mappings.
  7. How to convert YAML to JSON without surprisesIdentify the compatible subset, preserve types, and detect comments, anchors, tags, or keys that JSON cannot represent.
  8. How to convert JSON to YAML without losing typesLearn how to convert JSON to YAML preserving strings, numbers, booleans, and nulls, with testable examples and compatibility limits.
  9. JSON vs YAML: differences and when to use eachCompare syntax, types, comments, references, and interoperability to choose JSON or YAML for a specific job.

Reviewed on by Tools in a Tab.