Skip to content
cliplimeClipLime

Convert CSV to YAML

Paste a CSV or drop a file and get YAML, with values typed per column and risky text safely quoted.

Runs on your device, nothing is uploaded

Convert from

to

Paste, type, drop a file here or load one.

0 characters, 0 lines

Options

When off, columns are called column1, column2 and so on.

A column becomes numbers only if every filled cell in it is a clean number. All types also reads true/false, and empty cells and the words null and NULL become null.

Columns such as address.city become nested objects, and tags.0, tags.1 become a list.

Write each row as

A list per row starts with the column names when they are on.

Indentation

More options

The dot in address.city.

Empty cells do not create a key.

At a glance

Input
CSV or TSV text or a file. Commas, semicolons, tabs and pipes are detected, and quoted values and line breaks inside cells are handled.
Output
A YAML list with one mapping per row and the headers as keys, or a list of lists. Indentation is 2 or 4 spaces.
Types
Numbers, true and false, and empty cells (null) are detected per column. Choose Keep as text to leave every value a string.
Quoting
Text that a YAML reader could mistake for another type is quoted, such as the country code "NO", "007" or "2001-12-14".
Nesting
Headers such as address.city become nested mappings and tags.0, tags.1 become lists. You can turn that off.
Several lines
A cell with line breaks is written as a block, with |-, so it stays readable.
Privacy
Your CSV is converted in your browser tab and never uploaded.

How to do it

  1. 1

    Add your CSV

    Paste it, drop a file on the input box, or press Load a file. Example fills in a small CSV with quotes and a line break inside a cell.

  2. 2

    Choose how values are typed

    Under Cell values, pick Keep as text, Detect numbers or Detect all types. The delimiter is detected, and you can set it under Delimiter in the input.

  3. 3

    Pick the shape

    Write each row as an object or as a list, and decide whether dotted headers become nested values. Choose 2 or 4 spaces of indentation.

  4. 4

    Copy or download

    Press Copy, or Download to save a .yaml file.

From rows to a YAML list

Each row becomes one item of a YAML list: a dash, then a key: value line for every column, with the header as the keys. The header name,age and the row Ana,31 become - name: Ana followed by age: 31. Columns keep their order.

Without a header row, switch off First row has the column names and the keys are called column1, column2 and so on. Choose A list under Write each row as to get a list of lists instead, with the column names as the first list. Empty cells and the exact words null and NULL become null when all types are detected, and an empty string or the word itself otherwise.

Types, and why YAML quoting matters

Every cell in a CSV is text. In YAML the text 31 is a number, true is a boolean, and in older readers no is false. So the converter decides one column at a time: a column becomes numbers only if every filled cell in it is a clean number, with no leading zero and at most 15 digits.

  • A column with 1.10, 2.0 and 3.1 becomes the numbers 1.1, 2 and 3.1, because every cell is a clean number. If they are versions, choose Keep as text and they come out as "1.10", "2.0" and "3.1".
  • NO is quoted because older YAML readers take it for false. In the same column PT and FR stay plain, as they are not ambiguous.
  • 02134 and 007 stay text and are quoted, so a reader does not take them for numbers. ZIP codes and IDs keep their zeros.
  • Dates stay text and are quoted, as in joined: "2001-12-14", because many YAML readers turn an unquoted date into a date object.
  • A column that mixes numbers and words stays text in every row, so a column never has two types.

Text that would confuse the YAML syntax is quoted too: a value that starts with -, # or @, or contains a colon followed by a space.

Nested YAML from flat headers

Name the columns by path and the converter builds the structure. The headers name,address.city,address.zip,tags.0,tags.1 and the row Ana,Lisbon,1000-001,design,remote become:

  • name: Ana
  • address: with city: Lisbon and zip: 1000-001 indented under it
  • tags: with - design and - remote indented under it

Turn off Rebuild nested values from column names to keep each dotted header as one key, as in address.city: Lisbon. If the dot is part of your names, choose another separator under More options. Leave out empty cells drops a key instead of writing null. Headers that are whole numbers, such as years, are written in quotes ("2022": 1) so they stay keys.

Multi line cells and special characters

A quoted CSV cell can contain line breaks. In YAML it is written as a block, so notes: |- is followed by each line, indented. Long text is never folded onto several lines, and the converter takes care of quotes, colons and other characters that YAML treats as syntax.

Questions people ask

Why are some values in quotes?

Text that a YAML reader could take for something else is quoted: words such as no and yes, values with leading zeros, dates, and text that starts with a character YAML uses as syntax. A quoted value is text in every version of YAML.

Why did my version 1.10 become 1.1?

Every cell in that column is a clean number, so the column is written as numbers, and 1.10 is the number 1.1. Set Cell values to Keep as text and the column comes out as "1.10".

How do I keep ZIP codes and IDs as they are?

Values with a leading zero or more than 15 digits are never turned into numbers, so 02134 and long IDs stay text. For a column of ZIP codes without leading zeros, such as 10001, choose Keep as text.

How do I get nested YAML from a CSV?

Use dotted headers such as address.city, and numbered ones such as tags.0 and tags.1 for a list. With Rebuild nested values from column names on, each row becomes a nested mapping.

Can I get a list of lists instead of mappings?

Yes. Under Write each row as, choose A list. Each row becomes a list of its values, and the column names are the first list while First row has the column names is on.

Is my CSV uploaded?

No. The file is read and converted in your browser tab, so private data stays on your device.