Line Counter

Count lines in text instantly with our free Line Counter. See total, non-empty, and blank lines as you type.

Total Lines
0
Non-Empty Lines
0
Blank Lines
0
Avg. Words / Line 0 Averages are calculated using non-empty lines. Blank lines are excluded.
Avg. Characters / Line 0 Averages are calculated using non-empty lines. Blank lines are excluded.
Blank Lines
0
Avg. Words / Line
0 Averages are calculated using non-empty lines. Blank lines are excluded.
Avg. Characters / Line
0 Averages are calculated using non-empty lines. Blank lines are excluded.

Line Details

Blank lines:
Line Contents Line Length
1 No text entered

How to Use the Line Counter

To count lines in text, type or paste your text into the box above. The line count updates automatically as you type, so there is no button to press and no need to submit your text.

Total Lines counts all lines in your text, including blank lines. Non-Empty Lines shows how many lines contain text, while Blank Lines shows how many lines are empty.

The tool also calculates average words per line and average characters per line. These averages use non-empty lines only.

The Line Details table shows each individual line, along with its character count and word count. Character count is used as the primary measurement of line length.

You can control how blank lines are handled and sort the detailed results from longest to shortest, shortest to longest, or alphabetically from A–Z or Z–A.

Longest first and Shortest first sort lines by character count. Selecting Original order returns the table to the same order as your original text. Sorting Line Details does not change the text in the text box.

You can copy your original text, copy the Line Details results with line numbers, or download the detailed results as a CSV file for use in Microsoft Excel, Google Sheets, or another spreadsheet application.

What Counts as a Line?

A new line begins when the text contains an actual line break. In most text editors, this happens when you press the Enter or Return key.

For example, the following text contains three lines:

First line
Second line
Third line

Blank lines also count as lines in the main Total Lines result. If there is an empty line between two lines of text, the tool reports three total lines: two non-empty lines and one blank line.

In Line Details, you can choose whether blank lines are included, hidden while still counting toward the original line numbers, or excluded entirely.

Blank Lines vs. Non-Empty Lines

Total Lines counts every actual line in the text, including blank lines. Non-Empty Lines counts only lines that contain text, while Blank Lines shows how many lines contain no visible text.

The blank-line options in Line Details do not change the Total Lines, Non-Empty Lines, or Blank Lines statistics. They only control how the detailed results are displayed and numbered.

If a line appears blank but behaves unexpectedly, it may contain spaces, tabs, or an invisible Unicode character. Our Invisible Character Detector can help identify hidden characters in text.

Blank Line Options in Line Details

Line Details provides three ways to handle blank lines.

  • Include blank lines displays every line, including blank lines, using the original line numbering. This is the default.
  • Hide blank lines but count them removes blank rows from the table but preserves the original line numbers. For example, the visible lines may be numbered 1 and 3 when line 2 is blank.
  • Exclude blank lines removes blank lines from the detailed results and numbers the remaining lines consecutively.

Do Wrapped Lines Count as New Lines?

No. A line that automatically wraps because it is too long to fit across the screen is still one line unless the text contains an actual line break.

This is especially important on phones and narrow screens, where a long line may visually appear as two or three rows. The Line Counter uses the actual line breaks in your text rather than the way the text happens to wrap on your screen.

What Can You Use a Line Counter For?

Counting lines can be useful for many different types of text. Writers may want to check the length or structure of a document, while programmers may need to inspect lines of code, configuration files, logs, or data.

  • Count lines in documents, notes, or other text.
  • Count rows in text-based lists or datasets.
  • Compare total lines with non-empty lines.
  • Identify blank lines.
  • Find the longest or shortest lines by character count.
  • See word and character counts for individual lines.
  • Sort lists alphabetically without changing the original text.
  • Count lines in poems and other structured writing.
  • Copy text with line numbers.
  • Export line-by-line information to a CSV file.

For other ways to measure text, you can also use our character counter , Word Counter , Sentence Counter , or Paragraph Counter .

Counting Lines in Code and Data

A line counter can be useful when working with source code, logs, configuration files, CSV-style data, and other line-based information. Each actual newline is identified independently, making it easy to see how many rows or lines are present.

Character count is a useful measurement of line length for code and structured data because it can help identify unusually long lines. The Line Length column also includes the word count for each non-empty line.

The Hide blank lines but count them option can be particularly useful for code or data. It removes empty rows from the table while keeping the original line numbers, so a line displayed as line 27 still corresponds to line 27 in the original text.

Sorting the table also leaves the original text unchanged.

Counting Lines in Poetry

Line count is an important part of many poetic forms. Unlike a sentence , a poetic line does not need to end with punctuation or contain a complete grammatical thought.

Instead, a poetic line is generally determined by where the poet intentionally places a line break. This is why automatic word wrapping should not be confused with a new line in a poem.

The Line Length column shows both character and word counts, so writers can still compare the number of words in individual lines even though length sorting uses character count.

Some poetic forms have strict line requirements. A traditional haiku contains three lines, while a tanka contains five. A limerick normally contains five lines, and a traditional sonnet contains fourteen.

If you are writing a haiku, our Haiku Checker can check both the three-line structure and the traditional 5-7-5 syllable pattern. You can also use the Syllable Counter to count syllables in your lines.

Frequently Asked Questions

How do I count the number of lines in text?

Paste or type your text into the Line Counter above. The total number of lines is calculated automatically and updates as you type.

Do blank lines count in Total Lines?

Yes. Total Lines counts every actual line in your text, including blank lines. Non-Empty Lines gives you a separate count that excludes blank lines.

Can I exclude blank lines from Line Details?

Yes. Choose Exclude blank lines to remove blank lines from Line Details and number the remaining lines consecutively.

Can I hide blank lines without changing the original line numbers?

Yes. Choose Hide blank lines but count them. Blank rows disappear, but the remaining lines keep their original line numbers.

Does a wrapped line count as more than one line?

No. Text that wraps automatically because of the width of your screen is still considered one line. A new line is counted only when there is an actual line break in the text.

How is line length calculated?

Line length is primarily measured by character count. The Line Length column also displays the number of words in each non-empty line.

How do Longest first and Shortest first work?

Longest first and Shortest first sort the lines by character count. Blank lines remain at the bottom of the sorted results.

How are average words and characters per line calculated?

Average words per line and average characters per line are calculated using non-empty lines. Blank lines are excluded from these averages.

Can I sort the lines without changing my text?

Yes. Sorting affects only the Line Details table. You can sort by longest line, shortest line, A–Z, or Z–A while your original text remains unchanged.

What does Copy Text do?

Copy Text copies the original text exactly as it appears in the text box, including its original line breaks and blank lines.

What does Copy With Line Numbers do?

Copy With Line Numbers copies the lines from the current Line Details view with line numbers added. It follows the selected sorting and blank-line settings without changing the original text.

Can I download the line information?

Yes. Select Download CSV to save the line number, word count, character count, and contents of the lines in the current Line Details view.

More Text Tools

CharacterCounter.com has additional free tools for analyzing and working with text. Visit our text tools page to see all available counters, checkers, and converters.