Skip to content
Flow Style
step 1/5

Reading — step 1 of 5

Read

~1 min readFlow & Tags

Flow Style

Flow style is JSON-like inline syntax.

Maps:

person: {name: Alice, age: 30, active: true}

Lists:

fruits: [apple, banana, cherry]

Nested:

matrix: [[1, 2, 3], [4, 5, 6]]
people: [{name: Alice}, {name: Bob}]

Mixed block + flow:

config:
  servers: [web1, web2, web3]
  database:
    host: db.example.com
    port: 5432
    options: {timeout: 30, ssl: true}

When to use flow:

  • Short, simple lists: tags: [foo, bar, baz].
  • Inline single values.
  • Avoid for large structures (loses readability).

Strings in flow:

  • Bare strings work for simple identifiers.
  • Quote if value contains ,, ], }, :.
quoted: "name, with comma"
also: 'with: colon'

Flow vs block (same data):

# Flow:
person: {name: Alice, age: 30, emails: [a@b, a@c]}

# Block:
person:
  name: Alice
  age: 30
  emails:
    - a@b
    - a@c

Block is preferred for non-trivial data (more readable, easier diff).

Mixing modes is fine but stylistically inconsistent. Pick one per block.

Pure JSON IS valid YAML 1.2 (subset). Most YAML parsers accept JSON.

# valid YAML (which is also valid JSON):
{"name": "Alice", "age": 30}

Use case: emit JSON from your tool, output is YAML-compatible.

Limitations:

  • Can't have : in unquoted flow keys (parser confused with map key).
  • Can't have leading * or & in unquoted (parsed as alias/anchor).
  • Whitespace within values is more constrained.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…