Free online text tool

Length Sort

Length Sort sorts the lines of your text by length, from shortest to longest or from longest to shortest. Paste your lines, click the button and copy the sorted list. It is free and runs in your browser.

Sort Lines/Text by Length Tool

0Character Count
0Character Count (without spaces)
0Word Count
0Sentence Count
0Paragraph Count
0Line Count

Sort Lines/Text by Length Example

Sort direction: Ascending

Before
Sunset painted the sky in vivid hues and lighting.
Bookstores are cool.
The old clock in the hall chimed at midnight.
Rain fell.
She walked home slowly through the quiet park.
We left early.
After
Rain fell.
We left early.
Bookstores are cool.
The old clock in the hall chimed at midnight.
She walked home slowly through the quiet park.
Sunset painted the sky in vivid hues and lighting.

Bookmark: press Ctrl+D (Windows) or Cmd+D (Mac) to save this tool.

Suggest a New ToolProvide Feedback on This Tool

What does Length Sort do?

This tool sorts the lines of your text by length. Each line is kept whole, and only the order of the lines changes.

Choose Ascending to put the shortest line first, or Descending to put the longest line first. The length is the number of characters in the line, including spaces. Lines of the same length keep their original order, and empty lines are removed.

Use it to find the shortest or longest lines in a list, to order words or titles by size, or to tidy a list so that the lines get steadily longer.

Length sort examples

Each example shows your lines before and after sorting by length. The direction is shown in the Case column.

CaseBeforeAfter
Shortest first (ascending)
Sunset painted the sky in vivid hues and lighting.
Bookstores are cool.
The old clock in the hall chimed at midnight.
Rain fell.
She walked home slowly through the quiet park.
We left early.
Rain fell.
We left early.
Bookstores are cool.
The old clock in the hall chimed at midnight.
She walked home slowly through the quiet park.
Sunset painted the sky in vivid hues and lighting.
Longest first (descending)
Sunset painted the sky in vivid hues and lighting.
Bookstores are cool.
The old clock in the hall chimed at midnight.
Rain fell.
She walked home slowly through the quiet park.
We left early.
Sunset painted the sky in vivid hues and lighting.
She walked home slowly through the quiet park.
The old clock in the hall chimed at midnight.
Bookstores are cool.
We left early.
Rain fell.
Words by length
banana
fig
apple
kiwi
fig
kiwi
apple
banana
Same length keeps its order
cat
dog
ox
ant
ox
cat
dog
ant
Spaces are counted
a b c
abcd
ab
ab
abcd
a b c
Empty lines are removed
long line

hi
hi
long line

How to sort lines by length

  1. 1
    Add your lines
    Paste your text into the box, one item on each line, or import a text file.
  2. 2
    Choose the direction
    Pick Ascending for shortest first, or Descending for longest first.
  3. 3
    Click Length Sort
    The lines are sorted by length and shown in the box. Use Undo if you change your mind.
  4. 4
    Copy it
    Click Copy and paste the sorted list where you need it.

When to sort lines by length

Good for

Finding the shortest or longest lines, ordering words or titles by size, and tidying lists so the lines get steadily longer or shorter.

Check first

Put one item on each line. Spaces and punctuation count towards the length. Lines of the same length keep their original order. Empty lines are removed, and repeated lines are kept. The result replaces your text, so use Undo if you need the original.

Other tools

To sort A to Z try Alphabetical Sort. To see the length of each line try Find the Length of Each Line. To remove repeated lines try Remove Duplicate Lines.

Length sort FAQ

What does the Length Sort tool do?

It sorts the lines of your text by their length. You can put the shortest line first (ascending) or the longest line first (descending).

How do I sort lines by length?

Paste your lines, one on each line, choose Ascending or Descending in Sort direction, then click Length Sort. The sorted lines replace the text in the box. Click Copy to use them, or Undo to go back.

What does ascending and descending mean here?

Ascending puts the shortest line first and the longest line last. Descending does the opposite, with the longest line first.

How is the length of a line counted?

By the number of characters in the line, including spaces and punctuation. The line a b has 3 characters.

What happens to lines with the same length?

They keep the order they had in your text, in both Ascending and Descending.

Are empty lines kept?

No. Empty lines and lines with only spaces are removed, so the result is a clean list.

Does it remove duplicate lines?

No. A line that appears twice is kept twice. To remove repeated lines use Remove Duplicate Lines.

Can I sort words by length?

Yes. Put one word on each line. To sort the words of a sentence, first put each word on its own line.

Is this tool free and is my text private?

Yes. It is free, needs no account and runs in your browser, so your text is not uploaded to a server.

Looking for more text tools?

Browse Sorting Tools

Last updated: 10 November 2026