YAML
YAML is useful when you want an LLM, a Code node, or a human-editable text block to produce structured data without making the graph depend on brittle string parsing.
In this tutorial, you will turn text into an object with the Extract YAML Node, extract one field from that object, and then turn an object back into YAML with the To YAML Node.
Why YAML Helps
LLMs are often better at following a clear shape than at producing a one-line value. Instead of asking for "a title and three tasks" in plain text, ask for a YAML block:
yamlDocument:
title: Launch checklist
tasks:
- name: Write release notes
owner: Docs
- name: Build installer
owner: Release
- name: Smoke test app
owner: QA
Rivet can parse that into an object, which makes later nodes easier to connect and reason about.
Extract YAML
- Add a Text Node.
- Paste the YAML example above into the Text node.
- Add an Extract YAML Node.
- Connect the Text node output to the Extract YAML node
Input. - Run the graph.
The Extract YAML node looks for a root property name. By default that root is yamlDocument, so the example works without changing settings.
The Output port produces an object like:
{
"yamlDocument": {
"title": "Launch checklist",
"tasks": [
{ "name": "Write release notes", "owner": "Docs" },
{ "name": "Build installer", "owner": "Release" },
{ "name": "Smoke test app", "owner": "QA" }
]
}
}
If the input text does not contain a matching YAML block, the No Match output runs instead.
Extract One Value
The Extract YAML node can also extract one value from the parsed object.
- Open the Extract YAML node settings.
- Set
Object Pathto:
$.yamlDocument.tasks[0].owner
- Run the graph again.
The Output port now contains Docs.
Use JSONPath expressions in Object Path. A path that matches multiple values can also use the Matches output to return all matches.
Convert an Object to YAML
Use the To YAML Node when you already have an object and want a readable YAML string.
- Add an Object Node.
- Create an object with a few fields.
- Add a To YAML node.
- Connect the Object node output to the To YAML node
Objectinput. - Run the graph.
The To YAML node outputs a string. This is handy for prompts, logs, text files, and APIs that expect YAML.
Practical Pattern
A common low-code pattern is:
- Ask an LLM Chat node to answer in YAML under
yamlDocument. - Use Extract YAML to parse the answer.
- Use Extract Object Path or Destructure to pull out the fields the rest of the graph needs.
- Use To YAML only when you need to show or send the structured result as text again.
This keeps the graph structured internally even when the model response starts as text.