Line Counter

Count lines in any text, with separate totals for blank and non-blank lines, the longest line and the average line length.

Lines

0

Non-blank lines

0

Blank lines

0

Longest line

0chars

Avg line length

0.0chars

Words

0

Count lines in text, lists, data and code

A line counter counts the lines in a block of text. That sounds trivial until you need the answer for a list of 3,000 email addresses, a CSV export, a poem with a strict form or a code file. Paste your text above and the counter reports the total number of lines, how many contain text and how many are blank, the length of the longest line, and the average line length in characters.

What counts as a line

A line is everything between two line breaks. The first line runs from the start of the text to the first break, and the last line runs from the final break to the end. Windows and Unix line endings are both handled, so text copied from any operating system counts the same way.

One detail trips up a lot of tools. Most text files end with a line break, and a naive counter treats the empty space after it as one more line. This counter doesn't, so a file of 100 lines ending in a newline reports 100, not 101. That matches what text editors and command-line tools such as wc -l report for well-formed files.

A line that wraps in a narrow window is still one line. Wrapping is a matter of display, not content. The counter only looks at real line breaks, so the result doesn't change if you resize the window.

Blank and non-blank lines

The results separate lines with content from lines that are empty or contain only spaces and tabs. That distinction matters in practice. If you paste a list and want to know how many items it has, the non-blank count is the answer, because stray empty lines between entries won't inflate it. If you are checking formatting, the blank-line count shows how much vertical space you are using. The Blank Line Counter goes further and finds the longest run of consecutive blank lines.

Line length

The longest line and average line length are measured in characters, counting emoji and accented letters as one each. They are handy in several situations:

  • Code style: many projects limit lines to 80, 100 or 120 characters for readability, and the longest-line figure tells you at once whether a file complies.
  • Subtitles and captions: broadcast guidelines often recommend about 37 to 42 characters per subtitle line.
  • Poetry and lyrics: line length shapes rhythm, and comparing the average with the longest shows how regular a form is.
  • Data files: a line much longer than the average often means a missing delimiter or two records merged into one.

Who uses a line counter

Marketers count lines in contact lists and keyword lists before importing them into a tool with row limits. Developers count lines of code, configuration entries or log output. Data analysts sanity-check CSV and TSV exports before loading them. Poets and lyricists check sonnets (14 lines), haiku (3 lines), limericks (5 lines) and villanelles (19 lines). Translators and subtitlers check line-based deliverables, and teachers check line-numbered assignments.

Tips

If your count is higher than expected, look for blank lines between items. The non-blank figure ignores them. If it is lower, your source may separate items with commas or tabs rather than line breaks, and a quick find-and-replace in your editor will fix that. For counting paragraphs rather than lines, use the Paragraph Counter.

Counting lines in poems and verse

Poetic forms are often defined by their number of lines. A sonnet has 14, a villanelle 19, a limerick 5, a haiku 3, a rondeau 15 and a sestina 39, made of six six-line stanzas and a three-line envoi. Poets usually separate stanzas with a blank line, so the non-blank line count is the one to check against the form. The blank-line count tells you how many stanza breaks you've used. For syllable-based forms such as haiku, pair this with the Syllable Counter.

Counting lines in data

When you prepare a list for import, such as email addresses for a newsletter tool, product SKUs for a spreadsheet or keywords for an ad platform, the line count is your row count. Paste the list here before uploading it to confirm the number matches what you expect. Remember that a CSV file usually has a header row, so 1,001 lines means 1,000 records. If the average line length is around 30 characters and one line is 400, that line probably holds several records with the line breaks missing, or a field with an unescaped comma.

Why line endings sometimes confuse counters

Windows ends each line with two invisible characters, a carriage return and a line feed, while macOS and Linux use only the line feed. Text that has passed between systems can end up with a mixture, and some tools count the stray carriage returns as extra lines or extra characters. This counter treats both styles as one line break each, so the total is the same whatever system the text came from.

Runs locally

Like every tool here, the line counter works entirely in your browser. Lists of names, emails or other personal data never leave your device. For a wider set of statistics, try the Text Statistics Calculator or the full Word Counter.

How to use it

  1. 1

    Paste your text, list or code

    Each line break starts a new line, and a final trailing newline isn't counted as an extra line.

  2. 2

    Read the total

    The main figure is the number of lines, including blank ones.

  3. 3

    Separate content from blanks

    Non-blank lines tell you how many real entries a list has.

  4. 4

    Check line length

    Use the longest and average line length to check style limits or spot broken data rows.

Features

Accurate totals

Handles Windows and Unix line endings, and ignores a trailing newline.

Blank-line split

Separate counts for lines with content and empty lines.

Line length

Longest line and average length in characters.

Local only

Lists and data never leave your browser.

Häufig gestellte Fragen

Does a trailing newline add a line?

No. A final line break at the end of the text isn't counted as an extra empty line, which matches most text editors.

Do wrapped lines count as several lines?

No. Only real line breaks start a new line. Visual wrapping in a narrow window doesn't change the count.

How do I count items in a list?

Paste the list with one item per line and read the non-blank lines figure.

Can I count lines of code?

Yes. Paste the file contents. The blank-line count shows how much is whitespace.

How many lines is a sonnet?

A sonnet has 14 lines. Shakespearean sonnets use three quatrains and a couplet, and Petrarchan sonnets use an octave and a sestet.

Is my data uploaded?

No. The count is done on your device.

Rate Line Counter

No account needed, and ratings are anonymous.

How useful was this tool?
No ratings yet — be the first

Further reading

All articles →