Skip to content
TextArray
100% local

Collapse repeated lines

Merge consecutive identical lines into one, similar to the Unix uniq command.

Input

Collapse repeated lines

Collapse Repeated Lines removes consecutive duplicate lines from your text, keeping only the first (or last, or only once) of any group of identical adjacent lines. It works like the Unix uniq command: "a, a, b" becomes "a, b". Unlike Remove Duplicate Lines, which eliminates all duplicates from the entire text, this tool only affects lines that appear consecutively — so "a, b, a" stays unchanged because the duplicate "a"s are not adjacent.

This is useful when cleaning up logs with repeated entries, deduplicating output from batch jobs that print status messages multiple times, or tightening up data exports where records appear in sequential groups. You can choose to ignore case, treating "Apple", "apple", and "APPLE" as the same line. You can also trim leading and trailing whitespace before comparing, so " hello " and "hello" collapse together.

Everything runs in your browser. Your text is never uploaded anywhere, so it is safe for processing logs containing private information, database dumps, or any sensitive data. The live tally under the output shows how many lines collapsed and how many characters the result has. Copy it, download it as a .txt file, or send it to another tool when you are done.

FAQ

How is this different from Remove Duplicate Lines?
Remove Duplicate Lines deletes all occurrences of any line that appears more than once in the entire text. Collapse Repeated Lines only removes consecutive duplicates — so "a, b, a" remains unchanged here but becomes "a, b" there.
Can I trim whitespace before comparing lines?
Yes. Enable "Trim whitespace when comparing" and lines like " hello " and "hello" will collapse together, even though they look different. The trimmed version is only used for comparison; the original line is kept.
What happens with case-insensitive mode?
When "Ignore case" is checked, "Apple", "apple", and "APPLE" are treated as the same line. The first occurrence is kept with its original capitalization.
Is my text uploaded anywhere?
No. The collapsing runs entirely in your browser and your text never leaves your device.