Browse all lessons

Lesson 07 of 12 · 1:27 video · practice includedNot yet complete

Read YAML as structured data.

Build named values, lists and nested settings, then separate syntax from meaning.

WATCH THE LESSON1:27 · narrated walkthrough
Read the descriptive transcript

Follow the complete narration and the changes shown in the video. Each example can be copied.

1. Text on the left. Parsed data on the right.

YAML describes data using field names, values, and indentation. The right pane shows what a parser actually reads, as JSON. This is a practice canvas, not an agent running.

Source shown

title: Garden guide
draft: true
code: 007
tags:
  - planning
owner:
name: Mira

On screen

The cursor highlights the relevant source or result while the narration explains it.

2. 01 / A number or a string?

Look at code. Without quotes, zero zero seven is read as the number seven. An identifier may need its leading zeros. Put quotes around it.

Source shown

title: Garden guide
draft: true
code: "007"
tags:
  - planning
owner:
name: Mira

On screen

Quotes preserve an identifier as text.

3. A boolean is a different type of value.

Draft is true without quotes. It is a boolean, not the word true. A receiving application can require one type and reject the other.

Source shown

title: Garden guide
draft: true
code: "007"
tags:
  - planning
owner:
name: Mira

On screen

The cursor highlights the relevant source or result while the narration explains it.

4. 02 / Indent the child field

Name currently sits beside owner. The file parses, but owner has no value. Insert two spaces before name. Now the parsed result places Mira inside owner.

Source shown

title: Garden guide
draft: true
code: "007"
tags:
  - planning
owner:
  name: Mira

On screen

Valid syntax can still describe the wrong structure.

5. 03 / Add one list item

Click after planning. Start a new line with two spaces, a dash, and a space. Add writing. The right pane now shows two entries in the tags list.

Source shown

title: Garden guide
draft: true
code: "007"
tags:
  - planning
  - writing
owner:
  name: Mira

On screen

The source is edited character by character and its parsed result updates.

6. Read the result, then check the contract.

We have a title, a boolean draft flag, a quoted identifier, a list of tags, and an owner mapping. Parsing tells us the shape. The exercise checker separately checks the requested fields.

Source shown

title: Garden guide
draft: true
code: "007"
tags:
  - planning
  - writing
owner:
  name: Mira

On screen

The cursor highlights the relevant source or result while the narration explains it.

7. Your turn / Repair the structure

Pause here. In the exercise, add the tags and the nested owner. Then remove the indentation once, and compare the parsed result. A file can be valid YAML and still be wrong for its purpose.

Source shown

title: Garden guide
draft: true
code: "007"
tags:
  - planning
  - writing
owner:
  name: Mira

On screen

Try a deliberate mistake, then explain the difference.

What is YAML, and when would you use it?

YAML is a text format for structured data. Markdown gives prose headings and lists; YAML gives a program named values, ordered collections and nested records. A .yaml or .yml file commonly holds settings or metadata. It is not a programming language, and a value cannot perform an action by itself. YAML specification, introduction.

For this original exercise, imagine a tool that reads metadata for a garden guide. These names are our invented contract, not settings in editmd:

title: Garden guide
draft: true
code: '007'
tags:
  - planning
  - writing
owner:
  name: Mira

Read the shape before editing

title names a string. draft holds a boolean, while the quoted "007" stays text. tags holds a sequence; owner holds a mapping with its own name. Colons separate keys from values. Use spaces for indentation, not tabs. The nesting matters more than visual alignment. YAML collections, indentation.

Try reading the example aloud as a record: “The guide has a title, a draft state, a code, two tags and an owner.” If that sentence does not describe your intended data, a successful parse will not fix it.

Quote text that could be mistaken for something else

label: 'Plan: first draft'
reference: '#garden'
code: '007'
draft: false

Quoting makes the intended strings explicit. By contrast, false here is a boolean. A quoted "false" is a string. A receiving tool can reject the wrong type even when the YAML is valid. Comments begin with # in the appropriate position; the hash inside the quoted reference belongs to the string. YAML scalars.

A small mistake changes the data

owner:
name: Mira

This can parse, but name is a top-level key and owner has no supplied value. Indent name beneath owner to express the relationship. The exercise separates syntax errors from mismatches with its expected fields. Neither check knows whether Mira is the actual owner.

The local practice checker uses YAML 1.2 and deliberately excludes custom tags and aliases. That keeps this beginner exercise bounded; it does not mean those features are forbidden by YAML.

Practice, then transfer

Add the tags and owner to the starter. Compare the parsed result, then deliberately unindent name and check again. Finally, change the fictional owner and choose tags for a different document. Keep the structure; make the content your own. Do not put passwords or private account details in configuration examples.

Sources checked 17 September 2026. Host behavior can change; verify it against the linked documentation when using these examples.

YOUR TURN

Make the idea your own.

Add two tags and a nested owner mapping. Keep draft a boolean and quote the code so its leading zero stays visible.

garden.yamlText stays on this page

Parsed data and document

Parsed YAML (shown as JSON)

{
  "title": "Garden guide",
  "draft": true,
  "code": "007"
}

Compare with one possible answer
title: Garden guide
draft: true
code: "007"
tags:
  - planning
  - writing
owner:
  name: Mira

This is one approach. Your writing can differ while meeting the same structural goal.

TAKE IT WITH YOU

YAML represents data; the receiving tool decides what that data means.

Read the editor guide →
Agent-readable/learn/lessons/yaml-basics.md
Save .md