---
title: CSV
description: Convert between CSV text and items
---

Read CSV text into items, one per row, or turn items into CSV text.

## Try it

## What it does

CSV works in two directions, chosen with **Operation**:

* **Parse into items** reads CSV (or TSV) text and outputs one item per row, with the header names as field names. All values come out as text.
* **Build from items** takes all incoming items and writes them into one CSV text, one row per item.

It reads real-world CSV correctly: commas inside quoted values stay part of the value, a quoted value can span several lines, and `""` inside quotes means one quote character. Messy files are handled rather than rejected:

* A short row leaves its missing columns empty. A long row keeps the extra values as `column4`, `column5` and so on.
* A repeated header name is made unique (a second `price` becomes `price_2`), and an empty header cell is named by position (`column1`).
* An invisible byte order mark at the start of the file is removed, and both Windows and Unix line endings work.

When building, a value is quoted only when it needs it (it contains the delimiter, a quote, a line break, or leading or trailing spaces). Empty values become empty cells, and lists or objects are written as JSON. Columns are every field found across all items, in the order they first appear. Lines end with Windows line endings, which Excel expects.

## When to use it

* Read a spreadsheet export or a CSV returned by an API into items you can filter and sort.
* Produce CSV text from scraped items, to save with [Save as File](/nodes/builtin/datatransformation/saveasfile/) or send in a message.
* To get a CSV *file* (for an upload or attachment) instead of text, use [Convert to File](/nodes/builtin/datatransformation/converttofile/) with **Format** *CSV*.

## Inputs and settings

* **For parsing**: put the text in **CSV Text** (for example `{{ $input.body }}`), or leave it empty and name the field that holds it in **Source Field**. Turn off **First Row Is A Header** when the file has no header; the columns are then named `column1`, `column2` and so on.
* **For building**: **Columns** picks which fields to write and in what order. **Write A Header Row**, **Quote Every Field**, **Add Byte Order Mark** and **Put CSV In Field** apply only here.
* Choose *Tab* in **Delimiter** for TSV, and *Semicolon* for many European Excel exports.

## Outputs

* **Parse into items** outputs one item per data row, such as `{ "name": "Ada", "city": "London" }`. A file with only a header gives no items, not an error.
* **Build from items** outputs one item with the CSV text in **Put CSV In Field**, read downstream with `{{ $input.csv }}`.

## Dependencies and credentials

None. This node needs no connection and has no slots for other nodes.

## Example workflow

1. [HTML Extract](/nodes/builtin/datatransformation/html-extract/) reads a table of products from a page, one item per row.
2. CSV with **Operation** *Build from items*, **Columns** `name`, `price`, `url`, and **Add Byte Order Mark** on, since the file will be opened in Excel.
3. [Save as File](/nodes/builtin/datatransformation/saveasfile/) with **Content** `{{ $input.csv }}`, **File name** `products` and **File type** *csv* downloads the file.

## Common issues

* **"No CSV to parse. Fill in the CSV text, or name the field holding it on the incoming item."** Both **CSV Text** and **Source Field** are empty.
* **"Field "…" does not hold CSV text on the incoming item."** The field in **Source Field** is missing or is not text. Check its name in the previous node's output.
* **"No items to build CSV from. Connect a node that produces items."** Nothing reached the node when building.
* **Everything lands in one column.** The file uses another separator. Change **Delimiter** to *Semicolon*, *Tab* or *Pipe*.
* **Accented letters look garbled in Excel.** Turn on **Add Byte Order Mark** when building.

## Recipes with this node

## Related nodes

* [Convert to File](/nodes/builtin/datatransformation/converttofile/): produce a CSV file for uploads and attachments.
* [Extract From File](/nodes/builtin/datatransformation/extractfromfile/): read a CSV file that arrived as an attachment.
* [Edit Fields](/nodes/builtin/datatransformation/editfields/): tidy fields before building.
* [Sort](/nodes/builtin/datatransformation/sort/): order rows after parsing.