Text

Sort & Dedupe Lines

Sort lines of text alphabetically, remove duplicates, empty lines, and extra whitespace.

This tool sorts a list of lines alphabetically and removes duplicates and blank lines — a routine cleanup that's slow and error-prone to do by hand.

How to use it

Common uses

Things to keep in mind

Plain alphabetical sorting puts "file10" before "file2", since it compares strings character by character — natural sort is needed for the expected order with numbers.

Duplicate removal is case-sensitive by default — "Text" and "text" count as different lines unless the text is normalized to one case first.

Article about this tool: Sorting and deduplicating lines: why it matters

Frequently asked questions

What's the difference between case-sensitive and case-insensitive sorting?

With "Case-insensitive" off, uppercase and lowercase letters are sorted separately by character code; turned on, it compares lines regardless of case, bringing "Apple" and "apple" together.

How are duplicates, blank lines, and whitespace handled?

Two identical lines (according to the chosen case option) are considered duplicates and only the first is kept; "Trim whitespace" removes leading and trailing spaces before sorting, and "Remove blank lines" eliminates lines with no visible character.

Are my text lines sent to a server?

No, sorting and deduplication happen entirely in your browser in JavaScript — no data is transmitted elsewhere.

Why does "10" end up before "9" in alphabetical sorting?

Alphabetical (lexicographic) sorting compares strings character by character as text, not as numbers: "1" is lexicographically smaller than "9", so "10" comes before "9". For numeric order, the strings need to be parsed as numbers first.

Can I sort using natural order (natural sort)?

Natural sort recognizes digit runs within a string as numbers while comparing the rest as text — that's why "file2.txt" ends up before "file10.txt", which is useful for filenames or versions with a text prefix.

Articles: Text

Case Converter: why different naming styles exist

Why one project writes variables in camelCase but files in kebab-case, and where these rules came from.

Text Diff: how algorithms find the difference between two texts

How a diff algorithm finds the minimal set of changes between two versions of a text.

Regular expressions: basic syntax and common patterns

How to read a regular expression, and how greedy matching differs from lazy matching.

String Escape: why the same text needs escaping differently

Why the same quote character gets escaped differently in a JS string, JSON, and a shell command.

CRLF vs LF: why line ending characters still matter

Why a file written on Windows can show as "entirely changed" in git on Linux.

Counting characters and words: why it's not always trivial

Why an emoji or an accented character can count as several characters at once.

Lorem Ipsum: where the placeholder text came from and why it exists

Why designers deliberately use "nonsense" text instead of real content in mockups.

Slugify: turning arbitrary text into a URL

How a title like "Hello, World!" turns into a URL-safe string like hello-world.

Markdown: why plain-text syntax beat rich text editors

Why developers choose to write documentation in Markdown instead of a rich text editor.

Whitespace and invisible characters: the hidden cause of weird bugs

Why two strings that look identical can fail to match because of an invisible character.

Text Reverse: why "reversing text" is harder than it sounds

Why a naive string reversal can turn an emoji into unusable bytes.

Text frequency analysis: why count how often words repeat

How letter frequency in ciphertext helps crack the simplest substitution ciphers.