How to use the yaml to csv converter
- Paste your YAML into the text area. It must be a sequence (list) of mappings (objects).
- Choose a delimiter if you need semicolons or tabs instead of commas.
- The CSV output appears immediately below, with headers derived from your keys.
- Copy the result or download it for use in spreadsheets and databases.
How the yaml to csv conversion works
The converter reads a YAML sequence of mappings and flattens each mapping into a single row. Keys become the header columns. If a value is itself a mapping, its keys are joined with a dot. For example, address.city becomes a column header.
Consider this input:
- name: Alice
score: 95
- name: Bob
score: 80
The parser identifies two items in the sequence, each with keys name and score. The resulting CSV is:
name,score
Alice,95
Bob,80
Values that contain the chosen delimiter, double quotes, or newlines are wrapped in double quotes, and any internal double quotes are escaped by doubling them, following RFC 4180. This ensures the yaml to csv translation produces files that spreadsheet applications can open without errors.
Supported YAML subset
This tool implements a hand-written parser for a practical subset of YAML 1.2. It supports block sequences (lines starting with - ), block mappings (key: value), flow sequences ([a, b]), flow mappings ({a: 1}), plain scalars, single-quoted and double-quoted strings, block scalars using | (literal) and > (folded), and comments starting with #.
Features intentionally not supported include anchors (&), aliases (*), tags (!), merge keys (<<), and multi-document streams separated by ---. If your input uses these, the parser returns an explicit error rather than producing incorrect CSV data. If you need to check whether your file is well-formed before converting, run it through a YAML validator first.
Common use cases for yaml to csv
Converting yaml to csv is useful when exporting configuration data into spreadsheet software. Many static site generators and CI pipelines store structured data in YAML files. Flattening that data into CSV makes it easy to filter, sort, and chart in Excel or LibreOffice Calc.
Another common scenario is migrating data between systems. A database export might arrive as a YAML array of records. Converting it to CSV allows bulk import into relational databases or data warehouses that accept delimited text. You can also chain conversions: for instance, transform XML to YAML using an XML to YAML tool, then convert the result to CSV here.
Formatting rules and edge cases
The output follows RFC 4180 conventions. Every row ends with a carriage return and line feed (\r\n). Fields containing commas, double quotes, or line breaks are enclosed in double quotes. A double quote inside a field is represented as two consecutive double quotes.
If some objects lack a key that others have, the missing cell is left empty. The header row includes every unique key found across all objects, preserving the order of first appearance. Block scalars keep their internal line breaks (as plain line feeds), so the resulting CSV field spans multiple lines inside its quotes, which spreadsheet applications handle correctly. Numbers are written exactly as in the YAML (01234 keeps its leading zero), arrays become a JSON array in one cell, an empty mapping becomes {}, and null becomes an empty cell.
To reformat or tidy your YAML source before conversion, you can use a YAML formatter to ensure consistent indentation.
Reference: scalar types
| YAML syntax | Parsed value | CSV output |
|---|---|---|
plain text | String | plain text |
"double quoted" | String (escapes processed) | double quoted |
'single quoted' | String (no escapes except '') | single quoted |
123 | Number | 123 |
true | Boolean | true |
null or ~ | Null | (empty) |
| block | Multiline string | Quoted, line breaks kept as written |
Worked examples
| Example | Input | Result |
|---|---|---|
| Simple list of people | YAML input: - name: Alice / age: 30 / - name: Bob / age: 25; Delimiter: , | name,age / Alice,30 / Bob,25 |
| Nested object flattened | YAML input: - id: 1 / address: / city: London / zip: SW1A / - id: 2 / address: / city: Paris / zip: "75001"; Delimiter: , | id,address.city,address.zip / 1,London,SW1A / 2,Paris,75001 |
| Semicolon delimiter | YAML input: - product: Widget / price: 9.99 / - product: "Gadget, Pro" / price: 19.99; Delimiter: ; | product;price / Widget;9.99 / Gadget, Pro;19.99 |
FAQ
What structure does my YAML need to convert to CSV?
The root element must be a sequence (a list) where each item is a mapping (an object). A single mapping at the root or a plain scalar cannot produce tabular rows and columns.
How are nested objects handled?
Nested mappings are flattened using dot notation. A key named 'address' containing a mapping with 'city' becomes the column header 'address.city'.
Are anchors and aliases supported?
No. Anchors, aliases, tags, and merge keys are explicitly rejected with an error message. This prevents silently incorrect output. Use a full YAML library if you need those features.
Can I change the delimiter?
Yes. You can choose comma, semicolon, or tab as the field separator. Semicolons are common in European locales where commas serve as decimal separators.
Is my data sent to a server?
No. The conversion happens entirely in your browser using JavaScript. Nothing is uploaded anywhere.
Why do some CSV fields have double quotes around them?
Fields that contain the delimiter character, double quotes, or newlines are wrapped in double quotes per RFC 4180. Any double quote inside the field is doubled to escape it.