The Text Separator splits text on one delimiter and rejoins with another. Convert between newline-separated, comma-separated, tab-separated, and custom delimiters. Includes optional sorting, deduplication, and item counting.
case 'text-separator': { const cfg: Record<string, string> = {}; for (const line of (options.secondInput || '').split('\n')) { const eq = line.indexOf('='); if (eq > 0) cfg[line.slice(0, eq).trim()] = line.slice(eq + 1).trim(); } const sepMap: Record<string, string> = { newline: '\n', comma: ',', comma_space: ', ', semicolon: ';', tab: '\t', space: ' ', pipe: '|', }; const fromSep = cfg.from_sep === 'custom' ? (cfg.custom_from || ',') : (sepMap[cfg.from_sep] || '\n'); const toSep = cfg.to_sep === 'custom' ? (cfg.custom_to || ',') : (sepMap[cfg.to_sep] || ','); const doTrim = cfg.trim !== 'false'; const removeEmpty = cfg.remove_empty !== 'false'; let items = input.split(fromSep); if (doTrim) items = items.map(s => s.trim()); if (removeEmpty) items = items.filter(Boolean); let result: string; switch (action) { case 'sort': result = [...items].sort((a, b) => a.localeCompare(b)).join(toSep); break; case 'unique': result = [...new Set(items)].join(toSep); break; case 'count': result = `${items.length} items`; break; default: result = items.join(toSep); } return { output: result, meta: `${items.length} items | From: ${cfg.from_sep || 'newline'} → To: ${cfg.to_sep || 'comma'}` };}
The Text Separator handles edge cases like empty strings, leading/trailing whitespace, and custom delimiters with special characters (including multi-character delimiters).
For SQL IN clauses, first convert to comma-separated format, then wrap items with quotes manually or use the List Splitter tool with the sql_in template.
Custom delimiters that appear within items will cause incorrect splits. For complex data with embedded delimiters, use proper CSV parsing instead.