ETEvoraTools
Text Analysis

Line Counter

Line Counter returns 0 for the empty string; otherwise it converts CRLF to LF and counts split segments. A trailing LF creates a final empty line and therefore increases the count. Consecutive blank lines each create segments. Lone carriage returns are not recognized as separators, and visual wrapping in an editor does not create lines.

Runs locally — files stay on your device
Quick answer

Does a trailing newline add a line?

Yes.

Logical line separators differ from visual wraps

This page defines lines by stored LF boundaries after CRLF normalization, not by how text wraps on screen.

How it works

If input is nonempty, the shared line splitter returns an array whose length is displayed.

Key concepts

Empty input special case

It returns zero rather than one empty segment.

Trailing boundary

Text ending LF has a final empty segment.

When to use it

  • Count records in simple one-line-per-record text.
  • Measure explicit line breaks.
  • Check pasted log size.

When not to use it

  • Do not count visual wrapped rows.
  • Do not expect lone CR support.
  • Do not assume trailing newline is ignored.

Worked examples

Empty

Input
(empty input)
Expected output
0

Special case.

Two

Input
a\nb
Expected output
2

One separator.

Trailing

Input
a\n
Expected output
2

Final empty line counts.

Common mistakes

Comparing editor displays

Editors may hide final empty line. Correction: Agree on newline semantics.

Counting wrapped text

No stored separator exists. Correction: Measure layout separately.

Using old-Mac CR

It is not split. Correction: Normalize lone CR first.

Best practices

  • Specify whether final empty lines count.
  • Normalize line endings.
  • Use a format-aware record counter when needed.

Related operations and differences

Add Prefix to Every Line

Choose Add Prefix to Every Line when you need to add the same prefix before every line.; use Line Counter specifically for count lines.

Add Suffix to Every Line

Choose Add Suffix to Every Line when you need to add the same suffix after every line.; use Line Counter specifically for count lines.

Capitalize Every Word

Choose Capitalize Every Word when you need to capitalize the first character of every word.; use Line Counter specifically for count lines.

Extract Email Addresses

Choose Extract Email Addresses when you need to find unique email addresses in text.; use Line Counter specifically for count lines.

Extract URLs

Choose Extract URLs when you need to find unique HTTP and HTTPS links in text.; use Line Counter specifically for count lines.

Lowercase Converter

Choose Lowercase Converter when you need to convert every letter to lowercase.; use Line Counter specifically for count lines.

Limitations and privacy

  • CRLF/LF segments only; no lone-CR split, visual wraps, blank/nonblank breakdown, final-newline option, format parser, or line length statistics.

The text is analyzed locally in this browser and is not uploaded by the tool.

Frequently asked questions

What does empty input return?

0.

Does CRLF count as one break?

Yes.

Does trailing LF count?

Yes, as a final empty line.

Are wrapped rows counted?

No.

References