# Convert an Excel column to a comma-separated list

Canonical page: https://datalens.flazetech.in/guides/excel-column-to-comma-list

By [DataLens by Flazetech](https://datalens.flazetech.in/about).

Copy the cells in one spreadsheet column, paste them into the comma separator, and use New line as the input separator and Comma as the output. Review trimming, empty lines and duplicate settings before copying the result. Use a table converter when you need to preserve multiple columns.

[Open Comma separator](https://datalens.flazetech.in/convert-column-to-comma-separated-list)

## Convert a column without a spreadsheet formula

Select only the cells you want to include and copy them from Excel or Google Sheets. Paste them into Column input. Each line becomes one value. The output updates as you adjust settings, so you can review it before copying or downloading.

Leave Remove duplicates off if repeated values are meaningful. Leave sorting off when the original order matters. Trimming and empty-line removal are enabled by default, but can be changed in the cleanup controls. The converter does not add a trailing comma.

### Column input

```text
London
Mumbai
Tokyo
```

### Comma-separated output

```text
London,Mumbai,Tokyo
```

## Use TEXTJOIN when you want to stay in Excel

In Excel, TEXTJOIN combines a range using a chosen delimiter. The formula below joins A2 through A20 with commas and skips empty cells. Replace the range with your own. Use comma-space instead of comma if the result is intended for reading rather than a parser.

TEXTJOIN joins text; it does not add CSV escaping for every field. If a value contains a comma or a line break, review quoting before treating the result as CSV. For an interactive cleanup step, the comma separator offers quotes, duplicate removal and presets without changing the spreadsheet.

### Excel formula

```text
=TEXTJOIN(",",TRUE,A2:A20)
```

Reference: [Microsoft: TEXTJOIN function](https://support.microsoft.com/en-us/excel/functions/textjoin-function).

## Choose plain text, CSV quotes, a JSON array or a SQL list

Choose the output that the destination expects. A comma-separated string is not automatically a JSON array, and SQL string literals use different quoting from JSON. DataLens provides presets so you can inspect the exact result instead of manually adding brackets and quotes.

The SQL preset doubles embedded apostrophes. For example, O'Brien becomes 'O''Brien'. Use parameterized queries in application code; the preset prepares a list for review, not a database execution or query-security service.

| Destination | Example output | Setting |
| --- | --- | --- |
| Plain list | Alex,Sam | Comma separator |
| Quoted CSV values | "Alex","Sam" | Comma with double quotes |
| JSON array | ["Alex","Sam"] | JSON array preset |
| SQL string list | ('Alex','Sam') | SQL list preset |

## Preserve IDs, embedded commas and multiple columns

If the copied text contains 001 and 002, the list keeps those digits. The JSON array preset represents them as strings. However, a spreadsheet may already have removed leading zeroes before you copy the cells. Format identifier columns as text in the source and inspect the actual pasted values.

For names such as Smith, Alex, use double quotes around each output value so the comma inside the name is distinguishable from the separator. Embedded double quotes are escaped in quoted output. Use the CSV to JSON converter for records with several columns; flattening them into a single list loses the table structure.

To reverse the direction, open the delimiter converter, choose Comma as input and New line as output. Choose a custom separator for pipes, semicolons or another specific sequence. Conversion runs in the browser and does not modify the original spreadsheet.

## Related tools

- [Delimiter converter](https://datalens.flazetech.in/delimiter)
- [CSV ↔ JSON converter](https://datalens.flazetech.in/csv)
- [JSON formatter & validator](https://datalens.flazetech.in/json)
