Line Counter

Count the lines in any text, list, code or data file. The line counter shows total, non-empty, blank and duplicate lines, numbers every line with its length, and removes blank or duplicate lines in one click.

  • Opens text files
  • Stays on your device
0 lines
Files are read on this device

Line details

Every line with its number, length and word count. Sorting never changes your text.

Your lines appear here, numbered.

How to count lines in text

Counting lines with this line counter takes three steps.

  1. Paste text or open a file

    Paste a list, poem, code or data, or open a .txt, .csv, .log or code file. Files are read on your device, not uploaded.

  2. Read the line count

    Total lines, non-empty lines, blank lines and duplicate lines, plus average characters and words per line.

  3. Work with the lines

    Sort them, hide blank lines, copy them with line numbers, download a CSV, or remove blank and duplicate lines.

Example

“apples⏎bananas⏎⏎cherries” is 4 lines: 3 with text and 1 blank.

Count a sample list

Line counter features

The line counter does more than total your lines.

  • 4

    Line totals

    Total, non-empty, blank and duplicate lines, updated as you type.

  • #

    Numbered line list

    Every line with its number, characters and words. Hide blank lines with or without renumbering.

  • A–Z

    Sort and export

    Sort by length or alphabetically, copy with line numbers, or download a CSV.

  • 1

    One-click clean-up

    Remove blank lines or duplicate lines, with Undo if you change your mind.

What counts as a line?

A line ends where you press Enter (a line break). Text that wraps onto the next row on your screen is still one line, because wrapping changes with the width of the window.

Two more rules keep the count consistent:

  • A line break at the very end doesn’t add a line. That matches the POSIX definition of a line and the wc -l command, so a file ending in a line break isn’t counted one too many.
  • Windows, Mac and Linux line breaks (CRLF, CR and LF) all count once.

Total, non-empty, blank and duplicate lines

The line counter splits your lines into four counts, so you can see what your text is made of.

CountWhat it includes
Total linesEvery line, including blank ones.
Non-empty linesLines with at least one character that isn’t a space or tab.
Blank linesEmpty lines, and lines with only spaces or tabs.
Duplicate linesRepeats of a line that appeared earlier, ignoring spaces at the start and end. The first copy isn’t counted as a duplicate.
Average characters and words per lineWorked out from non-empty lines only, so blank lines don’t pull the average down.

Counting lines in code, CSV and log files

Open a file with Open file to count its lines without copying and pasting. Files up to 20 MB are read on your device.

  • Code: total lines include blank lines and comments. Use non-empty lines for a closer count of lines with code on them.
  • CSV files: each line is usually one row, so the number of records is the line count minus the header row. A field that contains a line break inside quotes adds an extra line.
  • Log files: one event per line, so the line count is the number of entries.

On a Mac or Linux, wc -l file.txt counts lines in a terminal. It counts line breaks, so if the file doesn’t end with one, the last line isn’t counted.

How many lines are in a poem?

Many poetic forms are defined by their number of lines, so a line counter is a quick way to check a poem.

FormLinesHow the lines are arranged
Haiku3Short, medium, short (often 5, 7 and 5 syllables in English).
Limerick5Rhyming AABBA.
Sonnet14Shakespearean: three four-line stanzas and a closing couplet.
Villanelle19Five three-line stanzas and a final four-line stanza.
Sestina39Six six-line stanzas and a three-line ending (envoi).

Remove blank lines and duplicate lines

Remove blank lines deletes every empty line, including lines with only spaces. Remove duplicates keeps the first copy of each line and deletes later repeats; it ignores spaces at the start and end of a line but treats capital letters as different. Both show how many lines were removed, and Undo brings your text back.

Line counter FAQ

How do I count the number of lines in text?

Paste the text into the line counter or open the file. The total appears straight away, with non-empty, blank and duplicate lines.

Do blank lines count?

Yes, in Total lines. Non-empty lines leaves them out, and Blank lines counts them on their own.

Does a wrapped line count as more than one line?

No. Only a line break starts a new line. Text that wraps on screen is still one line.

Why is my count different from my code editor?

Most editors show an extra numbered line after a final line break. The line counter doesn’t count that empty last line, the same as the wc -l command.

How do I count the lines in a file?

Choose Open file and pick a text, CSV, log or code file up to 20 MB. It’s read in your browser and never uploaded.

How do I remove duplicate lines?

Press Remove duplicates. The first copy of each line stays, later copies are deleted, and Undo brings them back.

How are the average characters and words per line worked out?

From non-empty lines only: total characters (or words) on those lines divided by the number of non-empty lines.

Is my text uploaded?

No. Text and files are counted in your browser and never leave your device.

Sources and references

  1. Base Definitions: Line (3.185), The Open Group (POSIX)
  2. wc invocation, GNU Coreutils manual