Remove Duplicate Lines | Keep First Occurrences

TextRuns in Your Browser (No Uploads)

Remove repeated lines from IDs, URLs, logs, and pasted lists while keeping the first original line. Choose exact case, trimmed comparison, or locale-aware natural sorting; bounded processing stays in a browser Worker.

What to do next

Continue with a related workflow or open the next tool that usually follows this task.

How to Use This Tool

Preserve the source before deduplicating when first-occurrence order, surrounding whitespace, or separator bytes are part of the contract.

Load one-item-per-line text from the editor or a local TXT, CSV, TSV, log, or Markdown file, staying within the visible byte and row caps.

Enable exact case only when case changes create distinct values.

Enable trimmed comparison only when surrounding whitespace should not distinguish rows.

Leave sorting off to preserve first-occurrence order, or enable it for a reviewable natural order.

Run the tool, compare source and unique counts, read any option or line-ending warning, then copy or download the result.

When to Use This Tool

Imported ID lists

Keep one copy of each identifier before a bulk admin action or spreadsheet lookup.

Log signal review

Collapse repeated log messages while retaining the first point at which each message appeared.

Configuration lists

Merge URL, hostname, allowlist, or denylist fragments and inspect exactly how many rows were removed.

Contact and label cleanup

Remove repeated email addresses or labels after deciding whether case and surrounding whitespace are meaningful.

Review-ready unique output

Produce a stable naturally sorted list for human review when the original order has no semantic value.

Common Mistakes

Sorting data whose order carries meaning

Logs, priority queues, and review trails often depend on chronology. Leave sorting off so the first occurrence order remains intact.

Ignoring case in machine identifiers

Identifiers may be case-sensitive even when human labels are not. Turn on exact case before deduplicating keys such as AbC1 and abc1.

Expecting trim comparison to rewrite output

Trimmed comparison changes only the comparison key. The tool keeps the first line exactly, including its surrounding spaces.

Assuming visually identical Unicode is identical

Composed é and decomposed e plus a combining mark remain separate because this tool does not apply Unicode normalization.

Skipping the line-ending result

Mixed LF, CRLF, and CR input is rewritten with the predominant source ending. Review the line-ending notice before a byte-sensitive import.

Examples

Keep the first imported ID

With case-insensitive comparison and sorting off, the first spelling and source order are retained.

Input
API-104
api-104
API-208
API-104
Output
API-104
API-208

Compare trimmed hostnames

Enable trimmed comparison to merge surrounding-space variants without modifying the kept first line.

Input
  alpha.example.com  
alpha.example.com
beta.example.com
Output
  alpha.example.com  
beta.example.com

Comparison, ordering, and line-ending contract

Line scanning preserves LF, CRLF, and CR separator evidence and treats a terminal separator as an ending marker rather than an extra value to deduplicate.

Each comparison key is stored in a Set-like map, giving average O(n) deduplication while retaining the first original line for each key.

Case-insensitive mode uses JavaScript lowercase conversion. Trimmed mode removes surrounding whitespace only from the comparison key; output content is not trimmed.

No Unicode normalization is applied. Code-point sequences that render alike can remain distinct unless their comparison keys are otherwise equal.

Natural sorting is applied only after deduplication through Intl.Collator for the active locale with numeric ordering; equal keys retain source order.

Inputs are capped at 1 MiB and 200,000 lines. Processing runs in a module Worker with a three-second deadline, and analytics records counts and options rather than source text.

Frequently Asked Questions

Does it preserve the first occurrence?

Yes. Sorting off preserves the first occurrence of every comparison key and the order in which those kept lines appeared.

How are case differences handled?

Comparison is case-insensitive by default. Enable exact case when Alpha and alpha must remain separate.

Does Ignore surrounding whitespace alter my text?

It trims only the temporary comparison key. The first kept line is returned byte-for-byte except when mixed line endings must be normalized.

Does it normalize Unicode before comparing?

No. NFC, NFD, NFKC, and NFKD are not applied, so canonically equivalent Unicode strings can remain distinct.

What happens to line endings?

For a uniform source, retained rows use its original LF, CRLF, or CR style and keep a final ending. Mixed sources choose the most common separator, with the earliest observed type resolving a tie.

How does Sort unique lines work?

Sorting runs after deduplication with the page locale, numeric ordering, and stable source order for equal sort keys. It is not a bytewise sort.

What are the processing and privacy limits?

A deduplication run is capped at 1,048,576 UTF-8 bytes and 200,000 source lines. It runs in a Worker with a three-second deadline and sends no line content in analytics.

How This Tool Was Verified

Maintained and tested by Reviewed

Method: To check “Preserve first-seen issue IDs”, we used Remove Duplicate Lines with the guide's exact source data and applied “Choose the case rule”. The output had to match the documented result; evidence for “Using case-insensitive matching for opaque IDs” and “Expecting trim comparison to clean the kept row” was reviewed before recording the check.

Expected result: Case-insensitive comparison reduced six issue-ID rows to four in first-seen order and reported two removals without sorting the surviving values.

Open the tested workflow

Related workflow guides

Use these focused guides when you need a practical workflow before opening the tool.

Related Tools

Continue with another maintained workflow

Browse All Tools