Skip to content
Line Tools
Remove blank lines, trim, dedupe, and sort.
Blog

Dedupe, Trim, and Sort Lines: What Changes the Result

Why do duplicates remain after sorting? Compare two fruit lists to see how adjacent dedupe, whole-list dedupe and blank-line removal differ.

Try the line tool →
Three key takeaways

Correction (September 28, 2026): We removed claims that trimming was automatic and that browser processing guaranteed input safety.

  1. ①
    Trim and dedupe are optional Only blank-line removal is on by default. Enable both trim and dedupe to merge lines that differ by trailing spaces.
  2. ②
    Whole-list is not adjacent-only Adjacent dedupe runs before sorting. Sorting can put surviving repeats next to each other; use whole-list dedupe for one copy of each line.
  3. ③
    Ticket IDs are text ticket-10 sorts before ticket-2. The tool does not sort numbers naturally or compare CSV columns separately.
A paper list with repeated fruit names crossed out beside a note reading 'Blanks and dupes gone'.

A list of emails or a log lands in your lap with blank lines mixed in, the same entry repeated, and invisible spaces clinging to the ends. Dropping it into a spreadsheet to run a dedupe, or writing a quick script, is more friction than the job deserves. Cleaning text by line takes a paste and a couple of checkboxes.

Clear blanks and duplicates in one go

Line cleaning rests on four operations: remove blank lines, trim whitespace, remove duplicates, and sort. They are far more useful together than apart.

Say you have hello , a blank line, world, hello, and a whitespace-only line. Turn on trim, remove blanks, dedupe, and sort ascending in the PiPi Worlds line tool, and the result collapses to hello and world. A live count shows how many lines remain, so you can see at a glance that the input went from several lines down to two.

Whole and adjacent dedupe are not the same

There are two kinds of dedupe, and the results differ more than you might expect.

Take the four lines apple, apple, banana, apple.

ModeResult
Whole-list dedupeapple, banana (2 lines)
Adjacent dedupeapple, banana, apple (3 lines)

Whole dedupe keeps the first occurrence of any line, no matter where the repeat sits. Adjacent dedupe removes a line only when it matches the one right above it, so the final apple survives because the line above it is banana. Reach for adjacent dedupe when you want to collapse runs without changing the order.

The order of operations decides the result

This is the part people miss. The operations run in a fixed order.

For options you enable, the order is trim, remove blanks, dedupe, sort, then numbering. By default, only blank-line removal is on. The lines apple and apple with a trailing space are different, so turn on both trim and dedupe to merge them. To treat Apple and apple as the same line, also turn on ‘Ignore case (dedupe/sort)’. Whole-list dedupe keeps the spelling that appeared first.

Why do duplicates remain after sorting?

Try this invented list in the English line tool. There are no spaces or blank lines in this first example:

apple
banana
apple

Keep Remove duplicates off, turn Adjacent only on, and select A → Z under Sort. Leave Trim, Ignore case and Number lines off. The result has three lines:

apple
apple
banana

That is not a failed comparison. Neither apple was adjacent to the other when dedupe ran. Sorting happens afterward and moves them together; the tool does not run dedupe again.

For one copy of each line, turn Adjacent only off and Remove duplicates on, keeping A → Z. You now get two lines:

apple
banana

For a record of consecutive runs, use Adjacent only with Sort set to None. Sorting changes the sequence you were trying to preserve. Keep an untouched copy of the original; fewer lines is not automatically a more accurate list.

A blank separator can change what counts as adjacent

Now paste this second invented list. The empty line in the middle matters:

apple

apple

Set Sort to None, Remove duplicates off, and Adjacent only on. Leave the other optional operations off.

  • With Remove blank lines on (the default), blank removal brings the two apple lines together before adjacent dedupe. The output is one line: apple.
  • With Remove blank lines off, the separator stays between them. The output is the original three-line list, including the empty middle line.

If blank lines separate batches in your notes, removing them discards that boundary. The tool does not know what a batch means. Preserve the separators or process each batch separately rather than treating the shorter output as proof that nothing important was lost.

Example check, 13 October 2026: we entered both harmless lists in the live English tool and compared these four results with its processing function. You can repeat the same checks in the public line tool. This checks the stated options and samples, not your private data or every browser.

Finish with sort and numbering

Two operations put the final shape on a cleaned list: sort and numbering.

Sort runs ascending (A→Z) or descending (Z→A). Turn on numbering and each line gets a 1., 2., 3. prefix in turn. Dedupe, sort, and number together, and a clean numbered list ready to paste into a doc or an email comes out in a single pass.

This is text sorting, not natural numeric sorting: ticket-10 sorts before ticket-2. If the sequence of ticket IDs or filenames matters, check it before sharing the output. The tool also compares whole lines, not CSV fields. A row such as name,email is not parsed into separate columns, so two rows with the same email and different names are not duplicates here.

Where are you cleaning that list?

The last point is about where the data sits. The lines you paste in to clean often carry email addresses, internal IDs, or log entries that should not wander off your machine.

The PiPi Worlds line tool transforms text in the browser and has no code that submits that input to our server. Cloudflare Web Analytics separately measures page views and load performance (Privacy Policy). That does not make every browser extension or device safe: test with anonymized data instead of real credentials, personal information, or internal logs. Mixed CRLF and LF endings become LF in the result. For the length of the cleaned list, use the word counter. If each line is a JSON value, check one line at a time in the JSON formatter; it does not accept a whole NDJSON list.

Frequently asked questions

What is the difference between whole and adjacent dedupe?
Whole-list dedupe removes every repeat anywhere and keeps the first occurrence of each line. Adjacent dedupe removes a line only when it matches the line directly above it. For example, apple, apple, banana, apple becomes apple, banana with whole dedupe, but apple, banana, apple with adjacent dedupe. Adjacent dedupe is handy for collapsing runs without reordering.
In what order are the operations applied?
For options you enable, the order is trim, remove blank lines, dedupe, sort, then number. Trim and dedupe are off by default. Turn both on if a trailing space should not stop two lines from matching.
Can lines that differ only in case be treated as the same?
Yes. Turn on 'Ignore case (dedupe/sort)' and Apple and apple compare as the same line for the selected dedupe and sort operations. Whole-list dedupe keeps the spelling that appeared first.
Does it handle text with Windows line endings?
Yes. CRLF, CR, and LF are all recognized, and the output is normalized to LF newlines. Text copied from a mix of Windows and Mac sources is cleaned in one pass.
Is the text I paste sent to a server?
The line transformation has no code that submits pasted text to our server. Cloudflare Web Analytics separately measures page views and performance. That is not a security guarantee for your browser or extensions; use anonymized examples rather than real personal data, credentials, or internal logs.

Sources

Review record: Codex AI code and example review (not a human security audit)

Recorded checks and limits

Checked src/lib/devtools/lines.js and ran the examples against its processing function. On 13 October 2026, reproduced four option combinations in the live English browser tool: adjacent dedupe before sorting, whole-list dedupe before sorting, and adjacent dedupe with blank removal on and off. The added input/output blocks are regression-tested against that same function; these are invented fruit lists, not user logs. The text transformation does not submit input to a server, but this does not certify the security of a browser, extensions, or an entire device.

What this guide adds — Adds two copyable fruit lists with exact outputs for four option combinations, including why sorting can leave adjacent repeats and why deleting a blank separator can merge two runs. Reproduces the published tool's default settings and operation order with small test lists, then checks cases where hidden spaces, identifier numbers, and case changes affect the result. It explains what the tool does not parse before readers use the output.

This records the stated checks; it is not an independent guarantee of accuracy.

Back to the tool →