EUComply

How to Convert YAML to CSV (3 Ways)

August 24, 2026 · 5 min read · Try the free converter →

Config lives in YAML, spreadsheets live in CSV. Sooner or later someone asks you for the Kubernetes inventory, the Docker Compose service list or the Ansible host vars as a spreadsheet. Here's how to get there without mangling the data.

Method 1: CLI Tools

Using transmute

$ cat services.yaml | qf --to csv
name,image,replicas
web,nginx:latest,3
api,node:20,2

qf auto-detects YAML on input, takes the top-level list of objects (or a named key containing one) and emits proper CSV headers. Nested maps are flattened with dot notation (resources.limits.cpu becomes its own column).

Using yq

$ yq -o=json eval services.yaml | jq -r '(.[0] | keys_unsorted) as $cols | $cols, .[] | [.[$cols[]]] | @csv'

There's no direct YAML→CSV path in yq, so this pipes through JSON and jq. It works, but it's two tools and a cryptic filter.

Method 2: Python (stdlib + PyYAML)

import yaml, csv, sys
data = yaml.safe_load(open("services.yaml"))
rows = data["services"] if isinstance(data, dict) else data
with open("out.csv", "w", newline="") as f:
    w = csv.DictWriter(f, fieldnames=rows[0].keys())
    w.writeheader()
    w.writerows(rows)

Fine for a one-off — but note it assumes flat rows. Nested values will serialize as Python dicts unless you flatten them first.

Method 3: Free Online Converter

Paste YAML into the browser converter and copy CSV out. It runs entirely client-side, so cluster names and internal hostnames never leave your machine.

The Hard Part: Lists of Lists

Reality check: YAML can express arbitrarily deep nesting; CSV is one flat table. Ports lists, volume mounts, environment maps — each needs a decision: join into one cell (8080|8443), repeat the parent row, or split into a second sheet. No tool makes that choice correctly for you, because it depends on what the reader wants.

Convert YAML → CSV in one click

Transmute runs the conversion on your machine — paste it in, or script it from the command line. JSON, YAML, CSV, TOML and XML, fully offline.

Get Transmute Desktop — $19 one-time →   Or use the free web converter