← All tools
// TEXT

Find Longest / Shortest Line

Identify the longest and shortest lines in any block of text — with line numbers and lengths.

Find Longest / Shortest Line logo
by
CHUNKY
MUNSTER
TEXT INPUT0 LINES

About Find Longest / Shortest Line

Analyses every line in your text and reports which is the longest and shortest (by character count), along with their line numbers. Also shows average and median line length. Runs entirely in your browser.

How to Use the Longest / Shortest Finder

  1. Paste or enter your input into the text field.
  2. Configure any options (format, delimiter, encoding, or mode) using the controls above the output.
  3. The result updates instantly — no submit button required for most operations.
  4. Click Copy or Download to take the output to your next step.

Paste any block of text — log output, prose, a CSV column — and the tool splits it on newlines (and again on whitespace for words) then sorts each list by length to find the extremes. Empty lines are excluded from the 'shortest' result so the answer is meaningful instead of always being zero.

How the Longest / Shortest Finder Works

Length is measured in JavaScript code units, which is fine for ASCII and most Latin text. Strings containing emoji or surrogate pairs may report a length one or two characters higher than what you visually count. Useful for checking whether title-tags fit Google's 60-char preview, finding the longest log line in a debug dump, or spotting an outlier row in a flat file.

Frequently Asked Questions

How is length measured — bytes or characters?

It uses JavaScript's String.length, which counts UTF-16 code units. ASCII and Latin text count as you'd expect; emoji and some CJK characters may add 2 to the count due to surrogate pairs.

Are empty lines counted as the shortest?

No — empty lines are excluded from the 'shortest line' calculation, otherwise the answer would always be 0. The longest result includes every non-empty line.

What if multiple lines tie for the longest?

The tool reports the count of ties and shows the first match. For example, if three lines all share the maximum length, you'll see 'Longest: 3 lines tied at 142 chars'.

Does it split words on punctuation or just whitespace?

Word mode splits on any whitespace (spaces, tabs, newlines). Punctuation stays attached — 'don't' counts as one 5-character word, not two.

Explore the full suite of TEXT tools and 290+ other free utilities at Chunky Munster.