Text grouping
Split a multi-line list into groups by group count (remainder goes to the first groups, so sizes differ by at most one) or by items per group; optionally sort by line length or text first, or use LPT balanced assignment to even out the characters per group. Every item keeps its original line number and nothing is dropped.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Grouping result
When splitting by group count the remainder goes to the first groups; balanced assignment places longest lines into the currently lightest group instead of round-robin by modulo.
Paste a list to group it
Items: 0 · Groups: 0 · Largest group: 0 · Smallest group: 0
What this tool does
- Split a roster evenly for activities, duties or a draw: the remainder goes to the first groups, so group sizes differ by at most one and each group can be checked by counting items.
- Shift or task planning: sort longest-first and use balanced assignment so each group gets a similar number of characters instead of one group taking all the long lines.
- Tidy a pasted list: sort the text to remove randomness, then cut it into fixed-size batches; the output keeps the original line numbers so nothing shifts.
- Batch processing of thousands of rows into fixed chunks you can paste straight into the next step.
Example
Input
张三 李四 王五 赵六 钱七 孙八 周九
Output
Text grouping (3 groups · input order · contiguous blocks) 7 lines split into 3 groups (largest 3 · smallest 2 · 14 characters in total) Group 1 (3 lines · 6 characters): 1. 张三 2. 李四 3. 王五 Group 2 (2 lines · 4 characters): 4. 赵六 5. 钱七 Group 3 (2 lines · 4 characters): 6. 孙八 7. 周九 Rule: empty lines are dropped, every item appears exactly once and the number is its line number in the original list; 7 = 3 + 2 + 2 = 7 lines, so nothing is lost.
The output above is the real result for "3 groups, input order, contiguous blocks": 7 lines into 3 groups, with the first groups taking the extra line (3 + 2 + 2 = 7). With balanced assignment the longest lines go into the currently lightest group, giving a similar character count per group.
Frequently asked questions
What does "remainder goes to the first groups" mean?
For a target group count the tool computes base = floor(total / groups) and remainder = total mod groups, then the first `remainder` groups take base + 1 items. Seven lines into three groups is 3 + 2 + 2 rather than 2 + 2 + 3, and no group is far larger than another.
How is balanced assignment different from contiguous blocks?
Contiguous blocks cut the list in order, so items inside a group are adjacent. Balanced assignment is an LPT approximation: lines are sorted by character count descending and each goes into the group with the smallest running total, evening out characters per group. Balanced characters and balanced counts are different goals: use contiguous blocks to even out counts.
Can a line be lost or duplicated?
No. Empty lines are ignored and every other line lands in exactly one group; the last line of the output prints the check "total = sum of group sizes" (for example 7 = 3 + 2 + 2 = 7). The number in front of each item is its line number in the original list, so sorting never hides its origin.
What if I ask for more groups than there are lines?
Every group keeps at least one line, so the group count collapses to the number of lines and the output says how many groups were actually used. Limits: 100 groups, 500 items per group and 5000 lines in total.
Does it read the clock or use the network?
No. Grouping is a pure function with no clock and no network access, and text sorting uses a fixed Chinese collation (Intl.Collator zh-Hans), so the same input gives the same output on every device.
Keywords:text groupingsplit list into groups