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.
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.
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 |
Code examples for scripting workflows.
Common developer workflows that require YAML from CSV data.
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 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.
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 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.
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.
-. Use a keyed mapping when the data has a natural unique identifier column and you need to look up records by that key.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.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.