How to convert CSV to YAML
Drop your CSV into the converter at the top of this page (or paste it). Pick an output mode — list of objects for sequences, keyed map for lookup-by-name configs — and the YAML appears instantly. Copy it, or download as .yaml or .yml. Runs entirely in your browser using PapaParse and an in-house YAML serializer — no upload.
- Upload your CSV or paste the contents.
- Pick the output mode:
- List of objects — each row becomes a
- key: valueblock in a YAML sequence. - Keyed map — one column becomes the top-level key. Use this for Kubernetes ConfigMaps, Helm
values.yaml, Ansiblehost_vars, or any config you look up by name.
- List of objects — each row becomes a
- Review the auto-typing. Integers, floats, and booleans (
true/false/yes/no) are emitted unquoted; empty cells becomenull; strings are quoted only when YAML requires it. - Download as
.yaml(default) or.yml, or copy to clipboard.
Going the other direction? See /yaml-to-csv/.
CSV to YAML examples
Three real-world examples — input on the left, output on the right.
Example 1: Kubernetes deployment list (list of objects)
Input CSV:
name,image,replicas,enabled
api,registry.example.com/api:1.4.2,3,true
worker,registry.example.com/worker:0.9.1,2,true
cron,registry.example.com/cron:1.0.0,1,false
Output YAML (list of objects):
- name: api
image: registry.example.com/api:1.4.2
replicas: 3
enabled: true
- name: worker
image: registry.example.com/worker:0.9.1
replicas: 2
enabled: true
- name: cron
image: registry.example.com/cron:1.0.0
replicas: 1
enabled: false
Drop this straight into a Helm values.yaml under a services: key, or iterate it from a template.
Example 2: Ansible host vars (keyed map)
Same kind of input — but you want to look up by hostname:
host,ip,role,disk_gb
web-01,10.0.1.10,frontend,80
web-02,10.0.1.11,frontend,80
db-01,10.0.2.10,database,500
Output YAML (keyed map, key column = host):
web-01:
ip: 10.0.1.10
role: frontend
disk_gb: 80
web-02:
ip: 10.0.1.11
role: frontend
disk_gb: 80
db-01:
ip: 10.0.2.10
role: database
disk_gb: 500
This is the exact shape Ansible expects in host_vars/ files when collapsed into a single inventory dict.
Example 3: GitHub Actions matrix (list of objects)
Input:
os,node,experimental
ubuntu-latest,18,false
ubuntu-latest,20,false
macos-latest,20,false
windows-latest,20,true
Output:
- os: ubuntu-latest
node: 18
experimental: false
- os: ubuntu-latest
node: 20
experimental: false
- os: macos-latest
node: 20
experimental: false
- os: windows-latest
node: 20
experimental: true
Paste under strategy.matrix.include: in your workflow YAML.
Auto-typing: numbers, booleans, nulls
YAML is whitespace-sensitive and type-sensitive. The converter follows YAML 1.2 rules so values come out with the right types:
| CSV cell | YAML output | Parsed as |
|---|---|---|
42 | 42 | integer |
3.14 | 3.14 | float |
1.5e10 | 1.5e10 | float (scientific) |
true / yes | true | boolean |
false / no | false | boolean |
| (empty) | null | null |
007 | "007" | string (zeros kept) |
Hello, world | "Hello, world" | string (quoted, has comma) |
Plain text | Plain text | string (unquoted) |
12:34 | "12:34" | string (colon needs quoting) |
Strings are quoted only when YAML would otherwise misread them — saves a lot of visual noise compared to dumb “quote everything” serializers.
How to convert CSV to YAML in Python / yq / Ruby
When the no-code converter doesn’t fit (CI pipelines, repeatable transforms), here are the standard library paths.
Python — csv + PyYAML
import csv, yaml
with open("services.csv") as f:
rows = list(csv.DictReader(f))
# Optional: cast types yourself — PyYAML's default dump won't.
for r in rows:
r["replicas"] = int(r["replicas"])
r["enabled"] = r["enabled"].lower() == "true"
with open("services.yaml", "w") as f:
yaml.safe_dump(rows, f, sort_keys=False, default_flow_style=False)
yq (one-liner, command line)
# Requires Mike Farah's yq (Go), not the Python one.
yq -p csv -o yaml services.csv > services.yaml
yq is the fastest path in shell pipelines but its type detection is more conservative than the converter above — strings that look like numbers get auto-typed without a leading-zero guard.
Ruby
require "csv"
require "yaml"
rows = CSV.read("services.csv", headers: true).map(&:to_h)
File.write("services.yaml", rows.to_yaml)
Common CSV-to-YAML problems
Special characters need quoting
YAML treats :, #, [, ], {, }, ,, &, *, !, |, >, ', ", %, @, and backtick as syntax. A value like 12:34 (looks like a time) or # comment will break parsing if emitted raw. The converter above quotes any string containing these characters automatically.
Leading zeros lost (007, ZIP codes, phone numbers)
A naive csv → JSON → YAML pipeline turns "007" into 7. The converter above keeps any number with a leading zero (other than just 0 or 0.x) as a string. If you’re using a different tool, mark these columns as text manually.
Indentation matters
YAML is whitespace-sensitive — the converter uses 2-space indent consistently, which is what every major YAML consumer (Kubernetes, Ansible, GitHub Actions, Docker Compose) expects. Don’t hand-edit the output and mix tabs in. Tabs are illegal in YAML indentation; the parser will reject the file.
true/false/yes/no as actual strings
Got a CSV column where yes and no are real string values, not booleans? The converter will type them as booleans. Either rename the values (Y / N, or accepted / declined), or hand-edit the YAML to add quotes around those specific entries.
When to use YAML vs JSON vs TOML
| Format | Best for | Avoid for |
|---|---|---|
| YAML | Configs, infrastructure-as-code, manifests | Data interchange between APIs |
| JSON | API payloads, machine-to-machine | Human-edited config files |
| TOML | App configs (Rust, Python pyproject.toml) | Deeply nested data |
YAML’s strength is human readability with structure: it’s the default for Kubernetes, Helm, Ansible, GitHub Actions, GitLab CI, Docker Compose, and most modern infra tooling. JSON is the right pick when a machine writes and a machine reads. TOML wins for flat-ish app configs but gets ugly when nested.
If your CSV is going to a REST API, JSON is usually the better target — there’s no dedicated CSV→JSON tool here, but you can pipe through Excel or use the patterns shown above. If it’s going into a config file or a manifest, you’re in the right place.
Privacy: nothing is uploaded
The CSV-to-YAML conversion runs entirely in your browser using PapaParse for parsing and a small in-house YAML serializer. No file ever reaches a server — verify in DevTools → Network. Useful when your CSV contains internal hostnames, credentials, customer data, or anything you wouldn’t paste into a public converter.
Working with related formats? See /yaml-to-csv/ for the reverse, /json-to-csv/ for JSON sources, or /csv-to-xml/ for XML targets.
Related tools
Convert any CSV file to a real .xlsx Excel workbook in seconds. Free, no signup, files never leave your browser.
Turn any .xlsx or .xls Excel file into a clean CSV. Pick the sheet, pick the delimiter, download. No upload.
Convert any Excel workbook (.xlsx or .xls) to a printable PDF in seconds. Pick the sheet, pick orientation, download. 100% private.
Convert any CSV file to a clean PDF table in seconds. Free, no signup, files never leave your browser.
Frequently asked questions
- How do I convert CSV to YAML?
Drop your CSV into the converter at the top of this page or paste the contents. Pick an output mode — list of objects or keyed map — and the YAML appears instantly. Copy it, or download as .yaml or .yml.
- What's the difference between list of objects and keyed map?
List of objects produces a YAML sequence: each row becomes a `- key: value` block. Keyed map turns one column into the top-level key — useful for Kubernetes ConfigMaps, Ansible host_vars, or any config where you look up entries by name rather than iterate them.
- How are types handled?
Integers, floats, and booleans (true/false/yes/no) are emitted unquoted so YAML parsers read them as the right type. Empty cells become null. Everything else is a string — quoted only when it contains YAML-special characters or looks like a number.
- Should I use .yaml or .yml?
Both work. The official recommendation from yaml.org since 2006 is .yaml. .yml is common in older Windows tooling and in projects like Ansible, Docker Compose, and GitHub Actions. Use whichever your project already uses — the converter outputs both.
- Does it handle large CSV files?
Yes — the parser (PapaParse) and the YAML serializer are both streaming-friendly and tested on files in the tens of MB. For multi-million-row CSVs, the bottleneck is the textarea rendering, not the conversion. Use the download button instead of viewing the output.
- Is this useful for Kubernetes or Ansible configs?
Yes — the keyed-map mode is built for exactly this. Convert a CSV of service names + replica counts into a values.yaml for Helm, or a CSV of hostnames + IPs into Ansible inventory variables. See examples below.
- What about leading zeros (007, phone numbers)?
Preserved as strings. A naive YAML serializer would turn '007' into the integer 7 — this one detects leading zeros and keeps them quoted. Same for ZIP codes starting with 0.
- Is my CSV uploaded?
No. The conversion runs entirely in your browser. Your data never reaches a server — verify in DevTools → Network. The page makes zero requests after it loads.