Line Counter

Count lines, non-empty lines, words, and characters in pasted text. Splits on CR, LF, or CRLF the way editors usually number rows.

Lines0
Non-empty lines0
Words0
Characters (no spaces)0
Characters (with spaces)0
UTF-16 length0

Spec

This line counter splits on \r\n, \n, or \r, drops a single trailing empty segment when the paste ends with a newline, then reports line count, non-empty lines, words, and characters. Word tokens follow Unicode letters and numbers when the engine supports \p{L}; otherwise it falls back to whitespace splits. Character totals are shown both with spaces and without, plus UTF-16 length (JavaScript string length) beside Unicode code-point length so emoji do not surprise you.

How lines are counted

An empty box is 0 lines. Text with no newline is 1 line. Line splitting uses the same CR/LF ideas documented on MDN String.prototype.split. Text that ends with a newline does not invent an extra blank row beyond the split parts, matching how many editors keep the caret on the last written line.

Non-empty lines ignore rows that are only whitespace, which helps when you paste logs that include blank separators.

Representative cases: empty paste → 0 lines; "hello" with no newline → 1 line; "a\nb" → 2 lines; "a\r\nb\r\n" → 2 lines after dropping the trailing empty segment; "a\n\nb" → 3 lines total and 2 non-empty.

Contrast with POSIX wc -l

POSIX wc defines the line count as the number of newline characters for newline-terminated input. A file that is exactly "hi" with no final newline can report 0 under wc -l, while this tool reports 1 line because editors still show one row of text.

That difference is intentional. Paste workflows usually care about visible rows, not whether the last byte was 0x0A. If you need byte-identical wc behavior for CI logs, keep using wc; use this page when you want editor-style numbering in the browser.

Words and characters

Words prefer Unicode letter and number runs so café counts as one word. Characters (no spaces) strip all whitespace; characters (with spaces) keep them.

Emoji and some symbols use surrogate pairs in UTF-16. JavaScript's string length counts those code units; the code-point total counts user-perceived characters more closely. Example: a single emoji may show UTF-16 length 2 and code-point length 1. Both numbers appear so copy-length limits and "how many glyphs" questions do not collide.

How to use this tool

Paste or type into the box. Totals update as you edit. No text leaves your browser; counting is local.

Use non-empty lines when blank separators should not inflate a log. Use UTF-16 length when matching APIs that store JavaScript strings; use code points when matching user-visible length.

Sister tool: sentence counter adds end-of-sentence detection and readability scores instead of line focus.

Frequently asked questions

Does a trailing newline add a blank line?

No. A single final empty segment after a trailing newline is dropped so the count matches common editor line numbering.

Are Windows and Mac line endings both supported?

Yes. The splitter accepts CR, LF, and CRLF in the same paste.

Is this the same as the sentence counter?

No. Here the focus is rows and size totals. The sister page scores sentences and readability instead.

Why does wc -l sometimes disagree?

POSIX wc -l counts newline characters. A last line without a newline can be 0 under wc while this tool still counts the visible row as 1.

Embed this calculator

Paste this snippet into any blog post or web page to get the working line counter, free to use, with the attribution link staying in place.

Readout check

Did this tool do the job?

Published by CalcBadger. Formulas verified against the sources above; last reviewed 2026-10-19.