The List Splitter divides lists into batches based on configurable criteria: items per group, character limits, or target group count. Supports multiple input delimiters, deduplication modes, and output templates including SQL IN clauses, JSON arrays, and CSV.
Key algorithms:Items Per Group (lib/tools/list-splitter.ts:48-55):
if (mode === 'items_per_group') { const chunks: string[][] = []; for (let i = 0; i < items.length; i += value) chunks.push(items.slice(i, i + value)); return buildGroups(chunks);}
Character Limit (lib/tools/list-splitter.ts:71-87):
const chunks: string[][] = [];let current: string[] = [];let len = 0;for (const item of items) { const sep = current.length > 0 ? 1 : 0; if (current.length > 0 && len + sep + item.length > value) { chunks.push(current); current = [item]; len = item.length; } else { current.push(item); len = current.length === 1 ? item.length : len + sep + item.length; }}if (current.length > 0) chunks.push(current);return buildGroups(chunks);
Target Group Count (lib/tools/list-splitter.ts:57-69):
if (mode === 'target_group_count') { const count = Math.min(value, items.length); const base = Math.floor(items.length / count); const remainder = items.length % count; const chunks: string[][] = []; let cursor = 0; for (let i = 0; i < count; i++) { const size = base + (i < remainder ? 1 : 0); chunks.push(items.slice(cursor, cursor + size)); cursor += size; } return buildGroups(chunks);}
The List Splitter was extracted from SplitBox and adapted for Kayston’s Forge. It handles edge cases like empty items, uneven splits, and special characters in values.
For SQL IN clauses with large lists, use items_per_group mode with value 500-1000 to stay within database parameter limits (e.g., Oracle 1000, SQL Server unlimited but practical limits apply).
When using max_chars_per_group mode, the character count includes separators. Very long individual items may exceed the limit if they can’t be split.