A line counter cheat sheet should make one rule explicit: total lines = non-blank lines + blank or whitespace-only lines, with each LF, CRLF, or lone CR treated as one line boundary.

That definition prevents most disagreements between a browser counter, an editor, and a command-line utility. This reference uses the documented behavior of Line Counter, which reports total lines, non-blank lines, blank or whitespace-only lines, and the longest line in Unicode code points. Text is analyzed directly in the browser, with no upload, submit action, account, or remote calculation required.

line counter cheat sheet
Line Counter Cheat Sheet: Boundaries and Blank Lines

The four results at a glance

Use each output for a specific question rather than treating all four measurements as interchangeable.

Result What it counts Important distinction
Total lines Logical segments separated by LF, CRLF, or lone CR A trailing boundary retains a final blank segment
Non-blank lines Segments containing at least one character after surrounding whitespace is trimmed Whitespace around visible text does not make the line blank
Blank or whitespace-only lines Segments containing only whitespace recognized by JavaScript trimming The original whitespace is not removed from the input
Longest line (code points) The greatest Unicode code-point length among the line segments It is not byte size, terminal width, grapheme count, or visual column count

The total is also a built-in consistency check: it must always equal the non-blank count plus the blank count. If it does not, the inputs or line-ending assumptions being compared are not actually equivalent.

Count lines with the browser tool

  1. Open Line Counter and type or paste plain text into the editor. Source code, logs, prose, lists, configuration, subtitles, and other plain text are supported. There is no upload or submit action.
  2. Read the four statistics as they update immediately: total lines, non-blank lines, blank or whitespace-only lines, and longest line measured in code points.
  3. Check that the total equals the sum of the non-blank and blank results. This confirms the classification without changing the pasted content.
  4. Before comparing the result with another program, note whether the source uses LF, CRLF, lone CR, or mixed endings, and whether it ends with a newline boundary.
  5. Compare the longest-line result by its unit. If another tool reports characters, bytes, terminal columns, or user-perceived symbols, its measurement may not match the code-point metric.
  6. Use Clear when starting over. It removes the entire input and returns every statistic to zero.

How newline boundaries are counted

Line counting becomes ambiguous when a program counts newline characters, logical records, or something else. The Line Counter rule is based on visible split structure: recognized line-ending sequences separate segments, and the resulting segments are retained.

Input condition Defined treatment
Empty input Contains zero lines
Any non-empty input Contains at least one logical line
LF Creates one line boundary
CRLF Creates one line boundary, not two
Lone CR Creates one line boundary
Mixed line endings Each recognized ending is accepted within the same input
Boundary at the end Produces a final blank segment that remains part of the count

One worked boundary example

Formula: total lines = non-blank lines + blank lines. Substituted case: alpha followed by one LF produces one non-blank segment and one blank trailing segment. Result: 2 total lines, with 1 non-blank line and 1 blank line.

CRLF is checked before lone CR or LF so that a Windows-style ending cannot accidentally create two boundaries. Mixed endings are useful when text has moved through Unix, Windows, classic Mac, terminal, or clipboard environments.

Blank lines and whitespace-only lines

A line is blank when trimming its surrounding Unicode whitespace leaves no content. This means a line containing only spaces, tabs, or other whitespace recognized by JavaScript trimming is counted as blank. A line with spaces around a letter is non-blank because visible content remains after the surrounding whitespace is removed.

The classification does not alter the source. Whitespace-only characters stay in the editor, and they still contribute to the length of the longest line. In other words, blankness and length are separate measurements: a line can be classified as blank while still having a measurable number of code points.

Because every segment is classified as either blank or non-blank, the results always support the same arithmetic check. That makes the total, non-blank, and blank figures suitable for quick auditing.

Longest line: code points, not columns

The longest-line result uses Unicode code points. A supplementary-plane emoji counts as one code point even though JavaScript stores it in two UTF-16 code units. A decomposed accented letter, such as e followed by a combining acute accent, counts as two code points even though it may render as one visible grapheme. A family emoji joined with zero-width joiners likewise contains several code points while appearing as one symbol.

This is a structural code-point count, not a visual measurement. Combining marks, variation selectors, and joiners each count separately. Tabs count as one code point even when an editor displays them across multiple columns. The tool does not normalize Unicode, expand tabs, or convert the result into bytes.

Consequently, the same visible symbol can have different lengths under code-point, grapheme, UTF-16, byte, and terminal-width rules. Those figures should not be compared as though they measure the same thing.

Why editor totals can differ

Some editors describe lines as newline characters, some report logical records, and some suppress a final empty segment. A program that counts newline characters can therefore disagree with a segment-based counter even when both process the same file. For a deeper explanation of this distinction, see Count Lines in a File With Clear Boundary Rules.

For a reliable comparison, establish three facts on both sides: the line-ending convention, the treatment of a trailing newline, and the Unicode normalization used. The Line Counter accepts LF, CRLF, CR, and mixed endings, but it does not normalize the text. If another program normalizes the input first, its longest-line measurement may differ even when the apparent characters look identical.

Visual wrapping is another common source of confusion. A long line that wraps inside the editor remains one logical line unless the text contains an actual LF, CRLF, or CR separator. The counter excludes soft-wrap display rows, words, sentences, bytes, paragraphs, and visual terminal width. Use dedicated counters when those separate measurements are needed.

Input limits and troubleshooting

The browser input guard is 1,000,000 JavaScript UTF-16 code units. The counter shown under the editor uses that same code-unit measurement. Text exactly at the limit is fully processed. If the input exceeds the limit by even one code unit, the entire analysis returns an error, all previous statistics disappear, and the tool never counts a prefix or silently truncates the remainder.

The input allowance is separate from the longest-line metric. A supplementary emoji uses two UTF-16 code units of the input allowance while contributing one code point to the longest-line length. This difference is intentional, so a long input containing emoji may approach the acceptance limit sooner than its code-point count suggests.

Everything is processed locally and deterministically. Entering the same sequence of UTF-16 code units produces the same statistics in supported browsers. The tool does not provide an optional numbered preview; use the editor itself to inspect the original text, while treating the four statistics as the complete results for accepted input. For a focused workflow for larger text blocks, read Line Counter Bulk: Count Large Text Blocks Locally.

Quick preflight checklist

  • Confirm that the input is at or below the 1,000,000 UTF-16 code-unit limit.
  • Check whether the source ends with LF, CRLF, or CR and whether a final blank segment should be counted.
  • Verify that total lines equal non-blank lines plus blank or whitespace-only lines.
  • Confirm that mixed line endings have not been converted differently by another tool.
  • Compare longest-line values in the same unit, especially around emoji, combining marks, joiners, and tabs.
  • Do not compare logical lines with soft-wrapped display rows, terminal columns, bytes, or grapheme clusters.