Text

Text Line Sorter & Deduplicator

Sort lines naturally or lexicographically, remove duplicate or empty lines, filter by regex, and wrap each line with prefixes or suffixes locally.

Free to use No sign-up Runs in your browser

Tool workspace

Input Lines (9)
Processed Output (6)
Removed: 3Duplicates: 2Empty: 1Filtered: 0

1. Sort & Deduplicate

2. Clean & Filter

3. Wrap, Number & Join

What Is a Text Line Sorter and Deduplicator?

Developers and data engineers frequently need to clean newline-delimited lists—such as environment variable keys, database IDs, log entries, or file paths—before running queries or scripts. Standard lexicographical sorting places 'item-10' before 'item-2' because it compares ASCII code points character by character. This workspace combines ECMAScript Intl.Collator natural sorting, numeric extraction, three deduplication strategies (unique, duplicates-only, singletons-only), regular expression line filtering, and SQL/JSON prefix-suffix wrapping in a single deterministic pipeline that executes entirely in browser memory.

How to Sort, Deduplicate, and Format Lines

  1. 1Paste your newline-delimited list, log snippet, or column values into the Input Lines box.
  2. 2Enable whitespace trimming and empty-line removal so trailing spaces do not create false duplicates.
  3. 3Choose a sort order (such as Natural A→Z so 'file-2' precedes 'file-10') and a deduplication mode.
  4. 4Optionally filter lines by substring or regular expression, or wrap each line with quotes and commas for SQL IN clauses, then copy the output.

Common Developer Workflows

Building SQL IN Clauses from Spreadsheet Columns

Paste a raw column of UUIDs or user IDs, strip duplicates and blank rows, and apply the SQL IN preset to wrap every item in single quotes separated by commas.

Isolating Duplicate Keys in .env or Config Files

Switch deduplication to 'Keep only duplicate lines' to immediately spot configuration keys or package names that appear more than once in a merged file.

Filtering and Sorting Application Log Lines

Use regular expression filtering with inverted matching to strip noisy health-check entries, then sort remaining error lines naturally by timestamp or identifier.

Frequently asked questions

Why does standard sort put 'item-10' before 'item-2', and how does Natural Sort fix it?

Lexicographical sort compares UTF-16 code units from left to right, where the character '1' (0x31) is smaller than '2' (0x32). Natural sort uses Intl.Collator with numeric: true so multi-digit numbers embedded inside strings are compared as integer values (2 < 10). In the terminal, the equivalent command is sort -V (GNU coreutils version sort).

Why does 'sort -u' or 'uniq' in Linux fail to remove some duplicate lines?

In POSIX shells, the uniq command only removes adjacent duplicate lines unless you pipe through sort first (sort file.txt | uniq), and trailing spaces or CRLF (\r\n) line endings cause visually identical lines to differ at the byte level. This tool normalizes CRLF to LF and trims whitespace before hashing lines in a Map, preserving original insertion order when sorting is disabled.

What is the difference between 'Keep only duplicate lines' and 'Keep only lines appearing once'?

'Keep only duplicate lines' (equivalent to sort | uniq -d) outputs each value that occurred two or more times, which is ideal for finding collisions. 'Keep only lines appearing once' (equivalent to sort | uniq -u) outputs only strict singletons and drops any value that had a duplicate.

Are my pasted logs or database IDs uploaded to a server?

No. All string splitting, regular expression matching, and sorting run synchronously in your browser's JavaScript engine with zero network requests.