📄

Line Counter

A line counter splits text at every line break and reports how many lines it holds. Paste four log rows with one blank line between them and a final line break and this page shows Total lines 6, Non-empty lines 4 and Empty lines 2, because that last break opens a sixth, empty line. Lines that contain only spaces or tabs count as empty, and Remove Empty Lines deletes them from the box in one click.

Text workspace

Count logical lines, identify blank lines and remove them from your text.

Method and limits

Paste text to see total, nonempty and empty lines. CRLF, CR and LF separate lines; a final newline adds an empty line. Empty text has zero lines. Removal keeps other line contents.

Screen wrapping does not add lines. Whitespace-only lines are empty. Unlike wc -l, this counts logical lines rather than newline characters.

Try this example

a\n\nb\n has 4 lines: 2 nonempty and 2 empty. Removing empty lines gives a\nb.

Total lines
Nonempty lines
Empty lines

Copied

Copy failed. Select the result and copy it manually.

Embed this tool on your website

Use whole pixel dimensions from 1 to 4096.

× px (1–4096)

                        

💡 Integration Tip

Copy the embed code and paste it into your website HTML. The responsive version adapts to all screen sizes automatically.

4.3
21 ratings
✓

Popular Tools

No more tools to show
Explore All Tools

About Line Counter

Count logical lines, identify blank lines and remove them from your text.

a\n\nb\n has 4 lines: 2 nonempty and 2 empty. Removing empty lines gives a\nb.

Screen wrapping does not add lines. Whitespace-only lines are empty. Unlike wc -l, this counts logical lines rather than newline characters.

Use Cases

A developer sizing a refactor pastes a source file and reads Non-empty lines, so the blank separator lines between functions are left out and the figure reflects the code that actually has to be reviewed.
A support engineer pastes a slice of an error log to see how many entries it holds before opening a ticket, and Empty lines exposes the double spacing some log shippers insert between records.
A data analyst pastes a CSV export and compares Total lines with the row count the database reported; a difference of exactly one usually means the file ends with a trailing line break, not that a row went missing.
A poet entering a competition capped at 40 lines pastes the poem and reads Non-empty lines for the verse count, while Total lines shows the figure that includes the stanza breaks.
A teacher building a vocabulary list pastes it, clicks Remove Empty Lines to strip the gaps left by copying out of a PDF, and checks that the counter now matches the 50 entries the exercise is supposed to have.

How to use

1

Paste text to see total, nonempty and empty lines. CRLF, CR and LF separate lines; a final newline adds an empty line. Empty text has zero lines. Removal keeps other line contents.

Pro Tips

  • Screen wrapping does not add lines. Whitespace-only lines are empty. Unlike wc -l, this counts logical lines rather than newline characters.

Troubleshooting

Problem:

What should the counters show after Clear?

Solution:

Clear removes all text and resets total, nonempty and empty lines to 0 / 0 / 0, just like an empty page. No reload is needed. A final newline in nonempty text still adds an empty line.

Problem:

The page freezes for several seconds when I paste a very long file.

Solution:

The number column on the left draws one row per line, so its cost grows with the file. In our tests 1,000 lines counted in well under a second, 10,000 lines took a few seconds and 50,000 lines took over a minute. Paste long logs in slices, or run wc -l on the file and add one to its answer.

Problem:

A line that looks blank is being counted under Non-empty lines.

Solution:

Something invisible is sitting on it. Spaces, tabs, carriage returns and non-breaking spaces are all ignored, so those still count as empty, but a zero-width space (U+200B) or a stray full stop is content. Delete the line and retype the break, or click Remove Empty Lines and check whether the row survives.

Frequently Asked Questions

Paste text to see total, nonempty and empty lines. CRLF, CR and LF separate lines; a final newline adds an empty line. Empty text has zero lines. Removal keeps other line contents.

Screen wrapping does not add lines. Whitespace-only lines are empty. Unlike wc -l, this counts logical lines rather than newline characters.

FreeWebTools AI