Skip to content

YAML to CSV converter

YAML to CSV reads YAML as structured records, then flattens nested mappings into a single CSV header before writing comma-delimited rows.

  • Converted with Table engine · nothing stored
  • Free: 5 conversions a day · 5 MB each
  • Higher limits →

From real runs

What you get — and what changes

  • YAML sequence Kept

    Two YAML list items became two CSV data rows beneath one shared header.

  • Nested mappings Changed

    customer.name and customer.city appeared as dotted CSV headers rather than nested YAML blocks.

  • YAML arrays Changed

    The tags list became a JSON string in the CSV cell and was quoted because it contains commas.

  • Null fields Changed

    YAML null values were written as empty CSV cells, so null and blank text are not distinguishable in the CSV.

  • Quoted numbers Kept

    The YAML strings 001 and 02134 stayed text in the CSV output and retained leading zeroes.

  • Unicode Kept

    München, Zoë, and 東京 were all present in the CSV bytes as UTF-8 text.

Sample conversions

Nested customer mapping

Input
YAML item had customer.name Ada, customer.city München, tags priority and quoted, comma, zip 02134.
Output
CSV header was id,customer.name,customer.city,tags,zip,active,total,due,empty and the tags cell was "[""priority"",""quoted, comma""]".

Null-to-blank conversion

Input
The first YAML record set empty: null, and the second omitted a separate extra object.
Output
CSV rows ended with blank empty cells, with no literal null token in the file.

A real YAML → CSV run

We converted our YAML sample (423 B) with Table engine on 2026-09-11. It took 2 ms and produced a 225 B CSV file, 47% smaller than the input. The engine raised no warnings.

Input · sample.yaml · 423 B

4 list items, 0 top-level keys, 20 lines

List items
4
Top-level keys
0
Lines
20

Output · sample.csv · 225 B

4 data rows × 5 columns; header: company,stage,arr,owner,close_date

Rows
4
Columns
5
Header
company,stage,arr,owner,close_date

First lines of the output

csv
company,stage,arr,owner,close_date
Northwind Traders,Proposal,48000,R. Ayers,2026-10-14
Contoso Ltd,Negotiation,120000,P. Ng,2026-09-30
Fabrikam,Qualified,22500,R. Ayers,2026-11-02
Tailspin Toys,Won,64000,M. Okafor,2026-09-03

Options and when to change them

flattenSeparator
Change this when dotted CSV headers conflict with existing field names or importer conventions.
arrayMode
Use json for variable arrays; choose explode only when indexed array columns fit the receiving CSV schema.
encoding
Use latin1 only for older YAML files that are not actually UTF-8.
delimiter
Pick semicolon or tab output when the CSV consumer expects a regional delimiter.
newline
Write CRLF when the file will be consumed by older Windows importers.

Do it yourself

Python PyYAML and csv

bash
python - <<'PY'
import csv, yaml
with open("input.yaml", encoding="utf-8") as f:
    rows = yaml.safe_load(f)
keys = sorted({k for row in rows for k in row.keys()})
with open("output.csv", "w", newline="", encoding="utf-8") as out:
    writer = csv.DictWriter(out, fieldnames=keys)
    writer.writeheader()
    writer.writerows(rows)
PY

This simple version handles only flat mappings; add a flattening step for nested YAML.

YAML to CSV by API or MCP

The HTTP API and the MCP server run the exact engine this page uses (Table engine); the response carries the same warnings the web converter shows. Check support first with GET /api/v1/pairs?from=yaml&to=csv.

curl
curl -X POST https://filetypeconverters.com/api/v1/convert \
  -H "Authorization: Bearer $FTC_API_KEY" \
  -F "file=@input.yaml" -F "from=yaml" -F "to=csv" \
  -F 'options={"encoding":"utf-8"}' \
  --output output.csv

Options this engine accepts for YAML → CSV

KeyApplies toTypeDefault
encodingReading YAMLutf-8 · latin1utf-8
flattenSeparatorReading YAMLstring.
arrayModeReading YAMLjson · explodejson
delimiterWriting CSVstring,
newlineWriting CSV ·
API reference

When this is the wrong conversion

  • Do not use CSV when nested YAML structure carries meaning that cannot be reduced to columns.
  • If null values must remain explicit null tokens, JSON output is clearer than an empty CSV cell.

YAML to CSV questions

How does YAML to CSV handle nested mappings?

Nested mappings flatten into dotted column names. In our sample, customer.name and customer.city became ordinary CSV headers.

Can YAML arrays fit into CSV cells?

They can, but they become serialized JSON text by default. That keeps the array visible but makes the CSV cell harder for spreadsheet users to edit.

Why did YAML null become an empty CSV cell?

CSV has no native null marker. The writer emitted an empty field, which many importers can later map to NULL if configured.