Sort and Shuffle Lines Online: Alphabetize, Reverse and Randomize a List
Paste your lines, one on each line, and choose what to do with them. The result appears at once. Everything happens in your browser: the text is not sent anywhere and is not saved.
What to do
In the template {line} is the line and {n} is its number. Write \n for a new line and \t for a tab in the fields. A ready template fills all the fields, and you can change them.
Fill the box
You do not have to type the lines. Take the names of files, or make a list of random numbers.
File list generator
Choose files or a whole folder, and their names appear in the box. Only the names, the paths and the sizes are read: the files are not opened and not uploaded.
Random numbers list
Whole numbers from the secure random generator of the browser.
Sort and Shuffle Lines Online
Paste a list, one item on each line, and this page puts it in order, reverses it, shuffles it, picks random lines from it or turns it into another kind of list. It replaces the old tools "List alphabetizer", "Reverse list" and "List randomizer", and does more: the sort understands numbers and other languages, the shuffle is fair, and you can take the lines from the names of your files. Everything happens in your browser, so the list is never sent to a server.
How to use it
- Paste the lines in the left box, or fill it with the names of files or with random numbers (the block "Fill the box").
- Choose the action in "What to do". The result is in the right box at once.
- Switch on the options if you need them: cut the spaces, remove the empty lines, remove the duplicates, ignore the case.
- Press Copy, or Download .txt. To work on the result again, press "Result to the left".
Sort lines alphabetically
"Sort A to Z" and "Sort Z to A" put the lines in the order of a dictionary. This is not the order of the codes of the characters, which puts all the capital letters before all the small ones and gives Apple, Cherry, apple, banana. With "Ignore the case" on, which is the default, you get Apple, apple, banana, Cherry. Switch it off if you need the strict order by codes.
The sort follows the rules of a language. Cyrillic, German letters with umlauts, French accents and the Polish or Turkish alphabets are put in their places when you choose the language, and the language of your browser is used if you do not. This is what people look for with "sort line ru": the same tool, with the Russian alphabet where ё stands after е.
Natural sort and sort by number
A plain sort puts file10 before file2, because the character 1 comes before 2. "Natural sort" reads the digits as a number, and gives file1, file2, file10. "By the first number in the line" sorts by the first number that it finds, so 2 pears comes before 10 apples; the lines with no number go to the end. A comma or a point can be the decimal sign (7,25 and 7.25). You can also put the shortest or the longest lines first.
Reverse text, lines and words
"Reverse text" can mean three things, and all of them are here:
- Reverse the order of the lines: the last line becomes the first.
a, b, cbecomesc, b, a. - Reverse the letters of every line:
hello worldbecomesdlrow olleh, and the lines stay in their places. - Reverse the whole text: the letters and the lines, from the end. The last letter of the last line is the first.
- Reverse the words of every line:
one two threebecomesthree two one.
A letter with an accent, or an emoji with a skin tone, is taken as one whole letter, so it is not broken in the middle. This works in all current browsers. In a very old browser the text is cut by code points, and a rare combined letter can come out wrong. If you need to flip the text upside down and not only back to front, use the fancy text generator.
Random list: shuffle and pick
"Shuffle the lines" puts them in a random order. The shuffle is the Fisher-Yates algorithm with the secure random numbers of the browser (crypto.getRandomValues), so every order has the same chance. "Pick random lines" takes the number of lines that you ask for: one line is a random choice from a list (a winner of a giveaway, a name, a place for lunch), and more lines are a random sample. With "No line twice" a line can be chosen only once. Press "Again" to draw once more.
Do not use it for a lottery that the law regulates: it is fair, but nobody can check the draw afterwards.
Random numbers list
In the block "Random numbers list" set how many numbers you need and the range, for example 10 numbers from 1 to 100, and press the button. With "No number twice" every number appears only once, which is what you need for a draw of tickets. The numbers are whole. For a single random number, set "How many" to 1.
Clean the list
The options work together with every action. "Remove the duplicate lines" keeps the first of the equal lines and shows how many were removed. With "Ignore the case" on, Apple and apple count as the same line. "Cut the spaces" removes the spaces and the tabs at the start and the end of every line.
List generator: a template for every line
The action "Make a list with a template" changes every line by a pattern, and joins them as you want. There are ready templates: one line with commas, a list for SQL IN (...), a JSON array, a list for Python or JavaScript, a CSV row, a Markdown list (bullets or numbers) and an HTML list. You can change the template, the quotes, the text between the lines and the text before and after all of them. In the template {line} is the line and {n} is its number.
A quote inside a line is escaped for the kind of quotes that you choose: a single quote is doubled for SQL (it''s), and a double quote gets a backslash.
MikroTik address list generator
A common use of the template is a list of addresses for the firewall of a MikroTik router. Paste the IP addresses or networks, one on each line, choose the template "MikroTik address list", and you get the commands of RouterOS:
/ip firewall address-list add list=blocklist address=203.0.113.5 /ip firewall address-list add list=blocklist address=198.51.100.0/24
Paste them into the terminal of the router. Change the name of the list in the template (list=blocklist), and add timeout=1d to it if the entries must disappear after a day. The tool does not check that the lines are addresses, so look at the result before you paste it.
File list generator
Press "Choose files" or "Choose a folder", and the names of the files appear in the box, one on each line. For a folder you get the paths inside it (photos/2026/img1.jpg), and you can switch off the path or add the size of every file. Then sort the list or give it a template. Only the names, the paths and the sizes are read: the browser does not open or upload the files. Choosing a folder does not work in some browsers on phones.
The same list from a command line:
- Linux and macOS:
ls -1 > list.txt, orfind . -type f > list.txtfor the files of all the folders. - Windows:
dir /b > list.txt, ordir /b /s > list.txtwith the subfolders.
The same in Python
lines = open("list.txt", encoding="utf-8").read().splitlines()
sorted(lines) # A-Z by the codes of the characters
sorted(lines, key=str.lower) # A-Z, ignoring the case
sorted(lines, reverse=True) # Z-A
lines[::-1] # the order of the lines reversed
text[::-1] # the letters of a text reversed
import random
random.shuffle(lines) # shuffles the list itself
random.choice(lines) # one random line
random.sample(lines, 3) # 3 different random lines
random is fine for a game or a draw among friends. For passwords and keys use the module secrets instead.
Limitations
- A line is the text between two line breaks. A very long line is one item.
- The order of a language comes from your browser. The same list can be sorted a little differently in two browsers, in the rare cases where the rules of a language are different in their versions.
- The page works with tens of thousands of lines. A list of millions of lines can make the browser slow.
- The text is not saved: only your choices stay in the browser.
- To count the lines, words and characters use the character counter, and to cut a text by a sign into lines use the text separator.
Similar tools
Separate text back and forth by new lines, commas, dots, etc.
Quickly transform your text formatting. Instantly switch between lower, upper, camel, Kebab, dash and snake case with the DIEG Case Converter. Free online tool.
Character counter and word counter online: characters with and without spaces, words, lines, sentences, pages, bytes, reading time, the numbers in a text with their sum, and a check against post limits.
Popular tools
Get the web-host of a given website.
Get approximate IP details.
Find A, AAAA, CNAME, MX, NS, TXT, SOA DNS records of a host.
Check the total size of a web page, including all resources, for performance analysis.