Home › Text Tools › Sort Lines by Length

Sort Lines by Length

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

  1. Paste your list with one item per line. A fruit list is loaded as an example.
  2. Choose the order: shortest to longest or longest to shortest.
  3. Pick how length is measured: characters, characters without spaces, words or pixel width.
  4. Choose a tie-break for lines with the same length: A to Z, Z to A or original order.
  5. 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:

LineCharactersWithout spacesWordsVisual width
ice cream982narrow (many thin letters)
WOMBAT661wide (capital W and M)
a to z643very narrow
👍🏽 ok431depends 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.

Related tools

Sort Lines AlphabeticallySort a list A-Z, Z-A, numerically, naturally or by length, or shuffle it.Line CounterCount total, non-empty, blank and unique lines in text or a .txt file, with line length stats.Remove Duplicate LinesDelete duplicate lines from any list, ignoring case or spaces, keep first or last, and sort.Sort Words AlphabeticallyPut the words in any text in A-Z or Z-A order, remove duplicates and pick a separator.Online Word ProcessorFree browser word processor with headings, lists, tables and images. Autosaves; export DOCX or PDF.Remove Line BreaksStrip line breaks and extra spaces, keep paragraphs if you want.Case ConverterConvert text to UPPERCASE, lowercase, Title Case, camelCase and more.MLA Format GeneratorBuild an MLA 9 heading, title page layout and Works Cited entries.Lorem Ipsum GeneratorGenerate placeholder text as paragraphs, words or lists, with HTML.Text RepeaterRepeat any text or emoji up to 100,000 times with custom separators.Find and Replace TextFind and replace words or regex patterns in any text, with match highlighting and undo.Add Line NumbersNumber every line of your text with custom start, step, padding and separator, or remove numbers.Add Prefix and Suffix to LinesAdd text to the start and end of every line: quotes, commas, bullets or SQL lists.Comma SeparatorTurn a column of lines into a comma separated list and back, with any delimiter.Text to Handwriting ConverterTurn typed text into realistic handwriting on notebook paper and save it as PNG or PDF.Japanese Kana ConverterConvert romaji to hiragana or katakana, kana to romaji, and hiragana to katakana instantly.Pinyin Tone ConverterTurn pinyin tone numbers (ni3 hao3) into tone marks (nǐ hǎo), or tone marks back into numbers.Remove Extra SpacesClean up double spaces, tabs, blank lines, non-breaking and invisible spaces in one click.Random Word GeneratorGenerate random English words by type, length, first letter and syllables, then copy them.List RandomizerShuffle a list into random order, pick random items or split it into fair teams.Email ExtractorPull every unique email address out of text or files, sort, filter by domain and export CSV.URL ExtractorExtract every link from text or HTML, remove duplicates, filter by domain or protocol.Strip HTML TagsRemove HTML tags and get clean plain text with line breaks and decoded entities.Online NotepadPrivate notepad that autosaves notes in your browser, with find, word count and .txt download.Remove PunctuationStrip all or only selected punctuation from text, with smart options for apostrophes and numbers.Text SplitterSplit long text into chunks by characters, words, lines or a delimiter, with numbering and copy.Remove AccentsStrip accents and diacritics from text (é→e, ñ→n, ß→ss, ø→o) instantly, live as you type.Sort NumbersPull numbers out of any text and sort them ascending or descending, with sum, average and median.Thread SplitterSplit long text into numbered X, Threads, Bluesky or Mastodon posts at sentence boundaries.Duplicate Word FinderFind repeated words in your text: doubled words like "the the" and overused words, highlighted.Alternating Caps GeneratorTurn text into aLtErNaTiNg caps, random caps or alternating words, then copy it.Random Paragraph GeneratorGenerate readable random English paragraphs by topic and length for writing and design.Random Sentence GeneratorGenerate random grammatical sentences: simple, compound, complex and questions.Markdown to Plain TextStrip Markdown syntax and keep clean plain text with lists, line breaks and link URLs.SRT to TextTurn SRT or VTT subtitles into a clean transcript with paragraphs, with or without timestamps.Transcript CleanerRemove timestamps, speaker labels and filler words like um and uh, and fix broken line breaks.Extract Numbers from TextPull every number out of text: decimals, negatives and percentages, with sum, average and CSV.Extract Phone NumbersFind phone numbers in any text, normalize them to E.164, remove duplicates and export CSV.Hidden Character DetectorFind and remove zero-width spaces, non-breaking spaces and other invisible Unicode characters.Letter to Number ConverterConvert letters to alphabet numbers (A=1 to Z=26) and back, with ASCII codes and letter sums.Markdown to Word ConverterConvert Markdown to a styled Word .docx file with headings, lists, tables, code and links.Plural GeneratorConvert English nouns from singular to plural and back, irregulars included, one word per line.Remove Empty LinesDelete blank and whitespace-only lines, or collapse gaps to one, with before/after line counts.Remove Text FormattingPaste rich text from Word, Google Docs or the web and get clean plain text instantly.Smart Quotes ConverterConvert curly quotes, dashes and ellipses to straight ASCII, or straight quotes to typographic ones.Text to HTML ConverterTurn plain text into clean HTML: paragraphs, line breaks, links, lists and escaped entities.Text to Word ConverterTurn text or a .txt file into a Word .docx with your font, margins and page size.WhatsApp Text FormatterFormat WhatsApp messages with bold, italic, strikethrough, monospace, lists and quotes, then copy.Word CombinerBlend two or more words into portmanteaus, compound and clipped names for brands and wordplay.Word to HTML ConverterConvert Word .docx files or pasted rich text into clean, semantic HTML with live preview.Word Wrap ToolWrap text at any column width with hard line breaks, indents and prefixes, or unwrap it again.Daily Affirmation GeneratorGet random positive affirmations by theme; save favorites, copy them or make an image card.Business Plan GeneratorFill in a guided form and get a formatted business plan with financial tables, as Word or PDF.Keyword Match Type ConverterTurn a keyword list into broad, "phrase", [exact] and negative match types for PPC ads.Discord Text FormatterFormat Discord messages with bold, spoilers, headers, quotes, lists and code blocks, with live preview.DNA Reverse ComplementGet the reverse, complement or reverse complement of DNA/RNA, FASTA and IUPAC codes supported.Filter Lines Containing TextKeep or remove lines that contain words or match a pattern, with match counts and regex.Focus Reading ConverterBold the first letters of every word for faster, focused reading. Copy as rich text or HTML.Memo GeneratorWrite a business memo in standard To/From/Date/Subject format, then print, copy or save as .docx.PDF Text CleanerFix text copied from a PDF: join broken lines, undo hyphen splits, drop page numbers and headers.Pros and Cons List MakerWeigh a decision with a weighted pros and cons list, a score, a verdict and easy export.Remove Numbers from TextStrip all numbers and digits from text, keep MP3-style words or ordinals, and tidy the spaces.Return Policy GeneratorCreate a return and refund policy for your store as text or HTML, with a refund example.Screenplay FormatterType a script in plain text (Fountain) and get a properly formatted screenplay, page count and PDF.Word ChangerSwap words for synonyms in your text, then click any word to cycle through alternatives.Words That End WithFind English words ending in any letters or suffix, filtered by length and sorted by score.Annotated Bibliography GeneratorBuild an APA or MLA annotated bibliography with hanging indents and download it as DOCX.EPUB to Text ConverterExtract plain text from EPUB e-books, pick chapters, count words and download a TXT file.
See all 96 Text Cleaning & Formatting →