Convert CSV to YAML
Proper quoting,
any structure.
Free CSV to YAML converter. Sequence of mappings or keyed object. Correct YAML scalar quoting — strings that look like booleans, numbers or reserved words are quoted automatically. Type coercion, custom indent. Runs in your browser.
YAML structure modes
Two idiomatic ways to represent tabular data in YAML.
- name: Alice age: 32 active: true - name: Bob age: 28 active: false
Each CSV row becomes a YAML mapping block starting with -. Maps directly to a list of dicts in Python, Ruby, Go and most YAML parsers. The most common structure for data files.
Alice: age: 32 active: true Bob: age: 28 active: false
First column (or chosen key column) becomes the top-level key. Maps to a dict of dicts. Useful for lookup tables, configuration files and data indexed by a unique identifier.
YAML string quoting — why it matters
Values that look like YAML keywords must be quoted — or they parse as the wrong type.
| CSV value | YAML output | Why |
|---|---|---|
| true | true | YAML boolean — no quotes needed (with type detection on) |
| yes | true | YAML treats yes/no/on/off as booleans in YAML 1.1 |
| True | 'True' | Capitalised — quoted to preserve as string if types off |
| null | null | YAML null — no quotes needed (with type detection on) |
| ~ | null | Tilde is YAML null shorthand |
| 42 | 42 | Integer — unquoted with type detection on |
| 0755 | '0755' | Octal-looking — quoted to preserve leading zero |
| Alice: Smith | 'Alice: Smith' | Contains `: ` — would parse as a mapping key |
| New York, NY | New York, NY | Commas are safe in YAML values — no quoting needed |
CSV to YAML in Python
Code examples for scripting workflows.
When do you need CSV to YAML?
Common developer workflows that require YAML from CSV data.
Configuration files
Application configuration and environment settings are often maintained in spreadsheets and need to be deployed as YAML config files. Converting the CSV to keyed YAML mapping produces a file that loads directly into any YAML-based config system (Kubernetes, Helm, Ansible).
Test fixtures and seed data
Test suites in Ruby on Rails, Django and many frameworks use YAML fixture files to seed databases. Converting a CSV dataset to YAML sequence-of-mappings produces fixture files ready to load with rails db:fixtures:load or Django's fixture framework.
Kubernetes and Helm values
Helm chart values files are YAML. Converting a CSV of environment-specific settings (hostnames, resource limits, feature flags) to keyed YAML produces a values file that overrides chart defaults per environment.
Ansible and infrastructure-as-code
Ansible inventory and variable files use YAML. Converting host lists or variable tables from CSV to YAML sequence-of-mappings produces files compatible with Ansible's group_vars and host_vars directory structure.
Related CSV tools
Other free converters on CSVShift you might need.
YAML generated
in your browser. Correctly.
Most CSV-to-YAML tools treat every value as a string and wrap it in quotes — producing valid but verbose YAML. CSVShift applies the correct YAML 1.2 scalar resolution rules: reserved words (true, false, null, yes, no, on, off) are detected and handled based on your type coercion setting. Strings that resemble reserved words but should stay as strings are quoted with the most appropriate quote style.
Correct YAML quoting
Block literal scalars
Two structure modes
Free, no conditions
How do I convert CSV to YAML?
What YAML structure is best for CSV data?
-. Use a keyed mapping when the data has a natural unique identifier column and you need to look up records by that key.How do I convert CSV to YAML in Python?
import csv, yaml; rows = list(csv.DictReader(open('f.csv'))); print(yaml.dump(rows, default_flow_style=False)). Requires pip install pyyaml. yaml.dump() applies correct YAML quoting — strings that resemble booleans or numbers are quoted automatically.Why do some string values get quoted in YAML?
true, yes, null, 42 as booleans, nulls and numbers respectively. If your CSV has a "status" column with the value yes that should stay as the string "yes", it must be quoted as 'yes' in YAML. With type coercion off, CSVShift quotes these values to preserve them as strings.