3tej home

What is Line Counter?

A Line Counter computes line counter from the inputs you provide. It applies the standard formula to the values you enter and returns the result instantly, without sending any data to a server. Total lines, non-blank, blank, longest line, shortest line, and average length across your text.

Line Counter

Counts lines in any pasted text: total, non-blank, blank, plus longest, shortest, and average line length.

Browser-onlyInstantFree foreverWorks offlineNo signup
← Utilities

TLDR

Paste any text and press Count. You'll see total lines, blank versus non-blank, longest and shortest, plus average length.

0 words · 0 chars
Runs entirely in your browser. No upload, no signup, no logging. Output is for personal or commercial use; we don't claim any rights.

About the line counter

The line counter splits any pasted text on newline characters and reports six numbers: total lines, non-blank lines, blank lines, longest line in characters, shortest non-blank line in characters, and average non-blank length. Everything happens locally in JavaScript, so a 5 MB log paste or a confidential SQL dump never leaves the browser tab. The split treats both Unix LF (\n) and Windows CRLF (\r\n) as one line break, so a Windows-formatted file and its Unix equivalent return identical totals.

This is functionally wc -l plus per-line length stats, but accessible without a terminal. Developers reach for it during pull-request review; data analysts use it to confirm a clipboard paste from Excel kept all the rows; technical writers use it to keep code samples under a style guide's "fits on one screen" cap.

How the counting works

Behind the button, the script runs text.split(/\r?\n/). That single regular expression handles three of the four line-ending conventions you encounter in the wild:

  • LF (\n): Unix, Linux, macOS since Mac OS X 10.0, modern Git.
  • CRLF (\r\n): Windows text files, HTTP headers, SMTP, most clipboard pastes from Notepad and Outlook.
  • CR-only (\r): classic Mac OS through System 9 (1984 to 2001). Rare today; this tool reports a CR-only file as one giant line.

Non-blank counting uses line.trim() !== '', so a line of only spaces, tabs, or other whitespace is classified as blank. That matches how IDEs, linters, and most LOC tools categorise blank lines.

Worked example: a 12-line SQL snippet

Paste this 12-line block:

SELECT
  customer_id,
  SUM(amount) AS total

FROM orders
WHERE created_at >= '2026-01-01'
  AND status = 'paid'

GROUP BY customer_id
HAVING total > 1000

ORDER BY total DESC;
Result: Total lines 12, non-blank 9, blank 3, longest 41 chars (the WHERE date filter), shortest 6 chars (the first SELECT keyword), average 22 chars. Useful for a code reviewer estimating cognitive load: 9 working lines is small; 30+ working lines usually warrants a comment block or a refactor.

Line-ending reference

ConventionBytesUsed byCounted by this tool?
LF0x0AUnix, Linux, modern macOS, GitYes
CRLF0x0D 0x0AWindows, HTTP, SMTP, OutlookYes (as one break)
CR-only0x0DClassic Mac OS pre-10.0 (1984-2001)No (treated as single line)
Unicode LSU+2028JavaScript template literals, rareNo
Form feed0x0CPage breaks in printer streamsNo

Common pitfalls

  • Counting CSV rows by line break. A CSV field can hold an embedded newline inside quotes; a real CSV row may span multiple physical lines. Parse with a CSV reader, not this tool, when you need row counts.
  • Confusing line count with LOC. A 5-line for-loop is 5 lines here, not 1 statement. For source lines of code, use cloc, scc, or your language's tooling.
  • Mixed line endings inflate diffs. A file saved as LF and another as CRLF report the same line count here but produce a "whole file changed" diff in Git. Run git config core.autocrlf input to normalise.
  • Excel paste off by one. Excel commonly appends an empty trailing row when you copy a selection; the count looks one higher than your visible data.
  • Notepad's "Word Wrap" lies. When Word Wrap is on, Notepad's status bar counts visual rows, not lines. Paste here for the real count.
  • Trailing newline confusion. POSIX text files end with a newline; the line after that newline is empty. This tool reports it as a blank line, which is correct.

Related text tools on 3Tej

Frequently asked questions

Does the tool count the final line if there is no trailing newline?

Yes. JavaScript's split returns the trailing content as its final element even when the string does not end in a newline, so a 5-line file without a trailing newline counts as 5. A 5-line file with a trailing newline counts as 6 because the empty string after the final break is itself a line.

Are Windows CRLF endings counted as two breaks?

No. The split regex /\r?\n/ matches an optional carriage return followed by a line feed, so each CRLF pair counts as one line break. A Windows-saved file and its Unix-saved twin produce identical line counts.

What counts as a blank line?

Any line whose trimmed content is the empty string. That includes truly empty lines, lines of only spaces, lines of only tabs, and lines mixing the two. The longest and shortest stats and the average length all ignore blank lines.

Is this the same as wc -l?

Close. wc -l counts newline characters only, so a file without a trailing newline reports one fewer line than this tool. For typical POSIX text files the two agree; for clipboard pastes lacking a trailing newline, this tool reports one more line. The numbers match what an editor or IDE shows.

Why does my Excel paste look one row too long?

Excel commonly appends an empty trailing row when copying a range, especially after using Ctrl+Shift+End or copying an entire column. The line counter reports the empty row as a blank line. Subtract one, or trim the trailing blank lines in a text editor before pasting.

Last updated 2026-05-28.