Paste a list and order it from the shortest line to the longest, or longest first. Measure length in characters, characters without spaces, words or on-screen width, and choose how lines of equal length are ordered.
Last updated:
0 lines
0 lines
Advertisement
Advertisement
How to use the Sort Lines by Length
Paste your list with one item per line. A fruit list is loaded as an example.
Choose the order: shortest to longest or longest to shortest.
Pick how length is measured: characters, characters without spaces, words or pixel width.
Choose a tie-break for lines with the same length: A to Z, Z to A or original order.
Press Sort by length, then copy the result or download it as text or CSV.
One list, four ways to measure length
The same lines can rank differently depending on what you count. Here is how four lines measure up in each mode:
Line
Characters
Without spaces
Words
Visual width
ice cream
9
8
2
narrow (many thin letters)
WOMBAT
6
6
1
wide (capital W and M)
a to z
6
4
3
very narrow
👍🏽 ok
4
3
1
depends on the emoji font
Words are runs of letters and digits; apostrophes and hyphens inside a word keep it whole, so don't and well-known count as one word each. Emoji are not words.
When sorting by length helps
Word games and puzzles: group candidate words from short to long, for example after unscrambling letters.
Character limits: sort headlines, product titles or SMS texts longest first to see which ones go over a limit.
Code and data: order CSS selectors, import lines or keywords by length for a tidy "pyramid" look, or find the longest value that must fit a database column.
Design: use visual width to find which button labels or menu items are widest before building a layout.
Writing: paste one sentence per line to spot your longest sentences.
Tips
Keep Trim spaces on: invisible spaces at the end of a line add to its length.
Average and median together tell you a lot: when the average is much higher than the median, a few very long lines are pulling it up.
Choose Keep original order as the tie-break for a stable sort, so lines of equal length stay in the order you gave them.
Frequently asked questions
How do I sort lines by length?
Paste the lines, choose Shortest → longest or Longest → shortest and press Sort by length. Each line is measured and the list is reordered by that number. The text of each line is not changed.
What happens when two lines have the same length?
By default lines of equal length are sorted alphabetically A to Z, so the result is always predictable. You can switch the tie-break to Z to A or keep the order the lines had in your original list.
Are spaces counted?
In Characters mode every space and punctuation mark counts, which matches what a database or form field limit measures. Choose Characters without spaces to ignore them, or Words to count whole words instead.
How are emoji and accented letters counted?
Each visible character counts as one, even if it is stored as several code units. An emoji like 👍🏽 or a flag counts as one character, and é counts as one, so the lengths match what you see.
What does visual width mean?
Visual width measures how many pixels a line takes when drawn in the page font at 16 px. Letters like W are wider than i, so two lines with the same character count can have different widths. It is useful for fitting labels, buttons or headings into a fixed space.
Can I see the length of each line?
Yes. Tick Show lengths in output to put the length in front of every line, or download the CSV, which has rank, line and length columns. Use as input automatically removes the length column first.
Is my list uploaded?
No. Sorting runs entirely in your browser and nothing is sent to a server.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.