---
title: "Comma List Toggle action for ActionClip"
canonical_url: "https://actionclip.app/actions/comma-list-toggle"
document_type: "standalone_action"
official: true
action_count: 1
catalog_schema_version: 1
catalog_revision: "2026-08-21.1"
catalog_published_at: "2026-08-20T18:50:00Z"
---

# Comma List Toggle action for ActionClip

Switch between comma-separated values and separate lines.

## What it does

Joins multiple non-empty lines with commas or splits one comma-separated line while respecting commas inside matching quotes.

## Action details

| Field | Value |
| --- | --- |
| Category | Text Editing & Formatting |
| Action type | JavaScript |
| Result | Replace or copy text |
| Internet | Not required |

## Action and outcome

| Action | Outcome |
| --- | --- |
| **Comma List Toggle** — Selected text: Apple, Banana, "Pear, green" | Apple Banana "Pear, green" |

## How to switch between comma-separated values and separate lines with ActionClip

1. Select the text you want to use.
2. Choose **Comma List Toggle** from ActionClip.
3. Review the result, then replace the selection or copy the new text.

## Requirements

No setup required.

## Privacy

Runs locally in ActionClip’s JavaScript sandbox. Selected text does not leave your Mac.

## Action configuration

````javascript
function run(selected_text) {
  const lines = selected_text
    .split(/\r\n?|\n/)
    .map((line) => line.trim())
    .filter((line) => line.length > 0);

  if (lines.length > 1) return lines.join(", ");
  if (lines.length === 0) return "";

  const values = [];
  let current = "";
  let quote = null;
  for (let index = 0; index < lines[0].length; index += 1) {
    const character = lines[0][index];
    if ((character === '"' || character === "'") && quote === null) {
      quote = character;
      current += character;
    } else if (character === quote) {
      if (lines[0][index + 1] === quote) {
        current += character + character;
        index += 1;
      } else {
        quote = null;
        current += character;
      }
    } else if (character === "," && quote === null) {
      if (current.trim()) values.push(current.trim());
      current = "";
    } else {
      current += character;
    }
  }
  if (current.trim()) values.push(current.trim());
  return values.length > 1 ? values.join("\n") : lines[0];
}
````

## Links

- [HTML listing](https://actionclip.app/actions/comma-list-toggle)
- [Download action definition](https://actionclip.app/actions/comma-list-toggle.actionclip)
- [Browse Text Editing & Formatting actions](https://actionclip.app/marketplace#marketplace-textTools)
- [All Marketplace listings](https://actionclip.app/marketplace)
