OnlineTextLab
Esc

CSV to YAML Converter

Spreadsheet rows become a YAML list of mappings, typed by column, with codes and odd strings safely quoted.

YAML output

Your YAML appears here as you type.

Nothing to paste yet? Use Try an example to see it work.

Options
Delimiter
Indent

Runs on your device. Your files and text are not uploaded.

About CSV to YAML

A lot of configuration begins as a spreadsheet someone keeps by hand: feature flags, inventory for an Ansible playbook, translations, a list of services. When it has to live in a repository, YAML is the usual destination, and retyping rows invites mistakes.

This converter makes one YAML mapping per row, using the header row for keys. Rows stay readable in a code review, and a later edit shows up as a small diff.

Because YAML has types and CSV does not, the conversion has to decide what each column holds. It does that by looking at the whole column, and you can switch it off.

How it works

The CSV is read with the same quote-aware parser as our other table tools, detecting the delimiter unless you choose one. Type detection is on by default here since config files usually want real values: a column of true and false becomes booleans, and a column of whole numbers becomes numbers. A single value that does not fit keeps that column as text, so 007 and 012 remain quoted strings.

An empty cell is null in a typed column and an empty string in a text column, so a blank in a numeric column does not become a stray text value.

On the way out, a string that a YAML reader could misinterpret gets double quotes, and a cell with line breaks becomes a | block. Keys that need it are quoted too.

How to use CSV to YAML

  1. Paste rows from a spreadsheet or CSV file, including the header line.
  2. Confirm each value's column in the Rows as read table.
  3. Under Options, switch off number and boolean detection if every value should stay text, and set the indent.
  4. Pick Copy or Download .yaml to save it.

Feature flags kept in a spreadsheet

Input
flag,enabled,rollout,team_code,description
new_checkout,true,25,007,"Faster checkout: one page"
dark_mode,false,0,012,
Output
- flag: new_checkout
  enabled: true
  rollout: 25
  team_code: "007"
  description: "Faster checkout: one page"
- flag: dark_mode
  enabled: false
  rollout: 0
  team_code: "012"
  description: ""

enabled and rollout became real values. team_code stayed quoted so its zeros survive, and the colon in description also forced quotes.

When it helps

  • Keeping feature flags in a sheet for product managers and generating the YAML that ships.
  • Building an Ansible variables list from an inventory spreadsheet.
  • Producing a data file for a static site generator from a table of team members or events.
  • Writing test parameter tables in a form that reads well in code review.

Tips for a better result

  • Name your columns as you want your keys, in lowercase with underscores if the consuming tool expects that. Headers are used as they are, apart from outer spaces being trimmed.
  • Turn off the first row header option only for genuinely header-less data, as the keys then become column_1, column_2 and so on.
  • Paste straight from Excel or Google Sheets if you like. Copied cells arrive separated by tabs, and the delimiter detection picks that up.

Good to know

  • The result is always a flat list of mappings. Dotted headers are not nested, so use CSV to JSON and then JSON to YAML if you need that.
  • No anchors or comments are written, even when rows repeat the same values.
  • Dates stay as quoted strings, which keeps them exact but means they are not YAML timestamps.
  • Numbers keep their value, not their format, so a column of 1.50 is written as 1.5.

Questions people ask

Why is a whole column of numbers quoted?

At least one value in that column does not convert cleanly, such as 007 or n/a, and the check covers the whole column. Look through it in the Rows as read table to find the odd one, or leave it if the column holds codes.

Can I get a mapping keyed by one column instead of a list?

Not directly. The output is a list with one item per row, which keeps duplicates and row order intact.

How are empty cells written?

In a column that was typed as numbers or booleans, an empty cell is null. In a text column it is an empty string, written as two double quotes.

Does quoting change the data?

No. A YAML reader gives you the same text whether or not it is in quotes. The quotes only stop it being read as another type.

What to use next

Last reviewed . Read our editorial policy.