{"title":"csv - Liquid Filter Reference","slug":"csv-filter-reference","url":"https://support.storeconnect.com/articles/csv-filter-reference","url_markdown":"https://support.storeconnect.com/articles/csv-filter-reference.md","subtitle":null,"summary":"Serializes a map or list as CSV text, the CSV counterpart of `json`. Use `csv` in a feed template to emit a whole CSV row or document built as a map or list of maps.","type":"Developer_Documentation","video_url":"","keywords":"liquid, filters, csv, collections, feeds, csv feed, serialize, storeconnect","last_modified":"2026-11-25T21:09:53+0000","body_markdown":"## Description\n\nSerializes a map or list as CSV. It is the CSV counterpart of [json](json-filter-reference), designed for [feed templates](set-up-a-feed).\n\n- A map becomes one row of the map's values, in key order, with no header.\n- A list of maps becomes a header row (the first map's keys) followed by one row per map.\n- A list of plain values becomes one comma-separated row.\n\nEach cell is escaped the same way as [csv_escape](csv-escape-filter-reference), and rows are separated by a line feed. A cell that holds a list or map has no CSV form, so build a flat map before you serialize it.\n\nIn a CSV feed, the output is marked as already encoded, so the feed does not escape it a second time.\n\n| Property | Value |\n|----------|-------|\n| **Return Type** | string |\n| **Category** | collections |\n\n## Examples\n\n\n```liquid\n\n{%- new Map row -%}\n{%- assign row = row | set_key: \"sku\", \"FR-3000\" | set_key: \"name\", \"Fridgetastic 3000, white\" -%}\n{{ row | csv }}\n```\n\n\n**Output:** `FR-3000,\"Fridgetastic 3000, white\"`\n\nCollect rows in a list to emit a whole CSV document with a header row:\n\n\n```liquid\n\n{%- new List rows -%}\n{%- for record in record_set.records -%}\n  {%- new Map row -%}\n  {%- assign row = row | set_key: \"code\", record.productcode | set_key: \"name\", record.name -%}\n  {%- assign rows = rows | push: row -%}\n{%- endfor -%}\n{{ rows | csv }}\n```\n\n\n**Output:** a header row `code,name`, then one row per record."}