Text

Sort & Deduplicate Lines

Paste one item per line. Sort A to Z, naturally or by number, remove duplicates and blank lines, count repeats, sort by a column, or shuffle. Your text never leaves your browser.

Ready. Paste or type one item per line.

What this tool does

Paste a list with one item per line and the result appears as you type. You can sort alphabetically, naturally (so file2 comes before file10) or by the number at the start of each line. You can also remove duplicate, repeated or empty lines, count how often each line occurs, sort by a column, number the result, reverse it or shuffle it. The tool works on plain lines of text. It is not a spreadsheet or a CSV parser.

The steps are always applied in this order: take the header line out (if you set one), trim spaces, remove empty lines, apply the duplicates option, sort, add counts, add line numbers, and put the header back on top. Lists of up to about 8 MiB are supported, and large lists are sorted in a background worker so the page stays responsive.

Alphabetical sorting and case

There are two ways to compare text, and they give different results for the same list. For the list banana, Apple, cherry, apple, Zebra:

SettingResult
Dictionary, ignore caseApple, apple, banana, cherry, Zebra
Dictionary, case-sensitiveapple, Apple, banana, cherry, Zebra
Code order, case-sensitiveApple, Zebra, apple, banana, cherry
  • Dictionary order follows language rules (the browser’s English collation). Accented letters sit next to their base letters, and with case-sensitivity on, a lowercase letter comes just before the same capital letter.
  • Code order compares Unicode code points. All capitals come before all lowercase letters, and accented letters come after z. This is the order of LC_ALL=C sort, and it is predictable across machines.
  • Ignore case treats Apple and apple as equal. Lines that compare equal keep their original order, because the sort is stable.
  • The collation is fixed to English so results do not change with your device settings. Other languages may expect a different order for their own letters.

Numeric, natural and lexicographic sorting

Text sorting compares character by character, so 10 comes before 9, because 1 is smaller than 9. Numbers need a numeric comparison.

OrderInput 10, 9, 100, 2, 1Input file10, file2, file1, file20, file3
Text (code order)1, 10, 100, 2, 9file1, file10, file2, file20, file3
Numeric1, 2, 9, 10, 100not meaningful: no number at the start
Natural1, 2, 9, 10, 100file1, file2, file3, file10, file20
  • Numeric uses the number at the very start of each line, optionally with a sign, decimals or an exponent (-5, 3.25, 1e3). Everything after the number is ignored for the comparison. Thousands separators are not understood, so 1,000 counts as 1. Lines with no leading number go last, in alphabetical order. Whole numbers are compared exactly, even beyond 15 digits, so long IDs are not rounded.
  • Natural compares each run of digits as a number anywhere in the line and the rest as text. It suits file names and version strings: 1.2.0, 1.2.10, 1.9.1, 1.10.0. It does not understand semantic-version pre-release tags such as -beta.
  • Length orders by the number of characters, with an emoji counted as one character.
  • When two lines compare as equal, they keep the order they had in the input (a stable sort). This also applies to the descending orders, which reverse the comparison, not the list.

Removing duplicates

The duplicates option works on whole lines. For the list a, b, a, c, b, a:

OptionResult
Keep duplicatesa, b, a, c, b, a
Remove duplicates (keep first)a, b, c
Remove duplicates and show counts3 a, 2 b, 1 c (most frequent first)
Keep only repeated linesa, b
Keep only lines that appear oncec
  • The first occurrence of each line is kept, and later copies are dropped before sorting, so the surviving lines come from the earliest position in your input.
  • With Ignore case on, Apple and apple are duplicates. The tool tells you when that merged lines that differed only in capitals.
  • Counts are shown like uniq -c: the count, a space, then the line. Choose Most frequent first to rank them.
  • The duplicates check always looks at the whole line, even when you sort by a column.

Whitespace, empty lines and line endings

  • Trailing spaces make lines different. api and api are not duplicates unless you turn on Trim spaces, and you cannot see the difference. Trimming removes ordinary and Unicode whitespace at both ends of each line.
  • Empty lines are kept by default and sort to the top. Remove empty lines also removes lines that contain only spaces.
  • Line endings. Windows (CRLF), Unix (LF) and old Mac (CR) endings are all recognised. The output uses the style of your input, and the tool says so when the input mixed several. A final line break is kept and does not count as an empty line.
  • Header rows. If the first line is a title or header, tick First line is a header so it stays on top and is not sorted with the data.

Sorting by column

Enter a column number to sort by the text in that position, split on a comma, tab, semicolon, pipe, colon, any run of whitespace or text of your own. The whole line is still output. For example, with the header option on, column 3 and a numeric descending order, the rows of id,name,score are ranked by score.

This is a plain split, not a CSV parser. A delimiter inside a quoted field ("Smith, Jo",42) is still treated as a delimiter, and quotes are not removed. A line with fewer columns counts as having an empty value there. For real CSV with quoting, use the CSV Viewer, which can sort a table by column, or the JSON ⇄ CSV Converter.

Common developer uses

TaskSettingsNotes
Package and dependency listsA to Z, ignore case, remove duplicatesA tidy, diff-friendly list. Do not sort files where order has meaning, such as lines that include -r or index options, or build steps.
Imports and require linesA to Z, code orderPlain line sorting only. Language tools such as isort or ESLint follow extra rules, so use them for the final order in a codebase.
Domains and hostnamesA to Z, ignore case, trim, remove duplicatesHostnames are case-insensitive, so duplicates differing in case are the same name.
IDs and numbersNumeric, low to highExact for whole numbers of any length. Use text order if the IDs have leading zeros you need to preserve in order.
Log linesA to Z, code orderLines that start with an ISO 8601 timestamp sort chronologically as plain text, for example 2026-10-09T07:59:12Z. Remove duplicates and counts show repeated messages.
Config values and allowlistsA to Z, trim, remove duplicatesCatch repeated entries in environment variables, feature flags or IP and domain allowlists.
File names and versionsNaturalapp-v2.js before app-v10.js, and 1.9.1 before 1.10.0.
CSV-like linesSort by column, header onFine for simple data without quoted delimiters.

Command-line equivalents

These shell commands do close to the same work. They are similar, not identical in every edge case: locale, how blanks are treated and where non-numeric lines are placed can differ.

Setting hereShell command
A to Z, code orderLC_ALL=C sort
Ignore casesort -f
Remove duplicates (keep first)sort -u sorts too; to keep the original order use awk '!seen[$0]++'
Numericsort -n
Natural / version ordersort -V
Counts, most frequent firstsort | uniq -c | sort -rn
Reverse ordertac
Shuffleshuf

During development the code-order, ignore-case, numeric, natural and duplicate options were compared with GNU sort and a Python reference on thousands of random lists.

Common mistakes

  • Sorting numbers as text and getting 1, 10, 2. Choose Numeric or Natural.
  • Expecting Apple and apple to be duplicates, or not expecting it. Check Ignore case.
  • Missing duplicates that differ only by a trailing space or a Windows line ending. Turn on Trim spaces.
  • Sorting a file together with its header row. Use the header option.
  • Assuming every tool orders accents and capitals the same way. Dictionary order, code order and your database’s collation can all differ. If a result must match another system, use the same rule there.
  • Sorting lines whose order matters, such as shell scripts, SQL statements or config files with overrides.

Before and after sorting

To see exactly what changed, paste the original and the result into the Text Diff Checker. To count lines, words or characters, use the Word & Character Counter. If your lines have inconsistent capitalisation, normalise them first with the Case Converter. Before putting list items into a string in code, escape them with the String Escape & Unescape tool. To pick lines out of a list by pattern, try the Regex Tester.

Frequently asked questions

How do I sort lines alphabetically?

Paste the list, leave the order on A to Z and copy the result. Use Z to A for the reverse.

How do I remove duplicate lines?

Choose Remove duplicates (keep first) in the Duplicates menu. To see which lines are repeated, choose Remove duplicates and show counts or Keep only repeated lines.

Why does 10 come before 9?

Text order compares characters. Switch to Numeric or Natural order.

Is the sort stable?

Yes. Lines that compare as equal keep their input order, in both ascending and descending sorts.

How large a list can I sort?

Up to about 8 MiB of text. The tool reports it if you go over, and nothing is cut off silently.

Is the shuffle truly random?

It uses the browser’s cryptographic random number generator. Do not use it for anything where a flaw would matter beyond ordinary shuffling.

Does it upload my list?

No. Everything runs in your browser.

Privacy and local processing

This tool runs entirely in your browser. Your lines are processed by JavaScript on this page, or by a worker started from this page, and are not sent to a server. Nothing is stored.

Share this tool

Your data is not included in this link.