Loading...
Loading...
Convert a CSV file to a YAML sequence of mappings. Each row becomes a YAML mapping with keys taken from the column headers.
The converter produces a YAML sequence where each item is a mapping. A mapping is a set of key-value pairs, one per column, separated by a colon and a space. Each item in the sequence is preceded by a dash. The output follows YAML 1.2 conventions and is valid for any YAML parser that supports the 1.1 or 1.2 spec, which covers the full ecosystem of modern tools.
String values that contain special YAML characters such as colons, hash symbols, or leading whitespace are automatically wrapped in double quotes. Numeric values are emitted as unquoted literals unless the type coercion option is disabled, in which case all values are quoted strings. Boolean-looking values like "true" and "false" are quoted by default to prevent YAML parsers from interpreting them as booleans when your data intends them as strings.
Ansible uses YAML for variable files and playbook data. If you have a list of hosts, users, or configuration parameters in a spreadsheet, converting to YAML gives you a variable file you can reference in a playbook with vars_files. The sequence-of-mappings structure maps directly to Ansible loops that iterate over a list of items.
Kubernetes ConfigMaps can store YAML-formatted data sections. A CSV of key-value configuration pairs converts cleanly to a YAML block that can be embedded in a ConfigMap manifest. Hugo static site generator uses YAML data files in the data/ directory to make structured content available to templates, so a CSV of product listings or team members can feed a Hugo site via a converted YAML file.
Test fixtures for Ruby on Rails, Django, and other web frameworks often use YAML. Seeding a test database with a set of records is straightforward when the data is already in a spreadsheet: convert to YAML and drop the file into your fixtures directory. The format aligns with what Rails expects for its YAML fixtures with minor adjustments to add record keys.
Can the output include YAML anchors or aliases?
No. The converter produces a flat sequence of mappings without YAML anchors. Anchors for shared values would need to be added manually after export.
What indentation does the output use?
The default indentation is two spaces, which is the most common convention for YAML files in infrastructure tooling. A four-space option is available if your project requires it.
Does it support multi-line cell values?
If a CSV cell contains a newline, the converter outputs the value as a YAML block scalar using the literal block style, which preserves the line breaks correctly.