Line Counter
Count total lines, non-empty lines, empty lines, and find the longest line in your text. Toggle a numbered gutter to see line numbers alongside your content.
How to use the line counter
Paste any text or code into the editor. The stats panel shows five metrics immediately: total lines, non-empty lines, empty lines, the longest line (with its full content in a tooltip), and average line length. Toggle “Show line numbers” to add a numbered gutter to the editor view — useful for navigating large pastes.
How line counting works
Lines are split on newline characters (\n). A CRLF sequence (Windows line endings) is treated as a single newline. The total count includes all lines, including any trailing empty line after a final newline. Empty lines are identified by testing that the line, after trimming whitespace, has zero length. Longest line is found by a single pass comparing line.length values.
When line count matters in development
Line count is a basic but useful metric in several contexts: verifying CSV exports have the right number of rows, checking that a log slice contains the expected events, confirming a generated file matches a specification, and enforcing line limits in code review (some teams flag files over 300 lines for refactoring). The empty line count helps identify files with excessive blank padding.
Frequently asked questions
What counts as a line?
A line is any segment of text terminated by a newline character (\n on Unix, \r\n on Windows). A completely empty line counts as one line. The total line count includes all lines — empty and non-empty. The 'Non-empty lines' stat excludes lines that contain only whitespace.
Why does my file have different line counts on Windows vs Mac?
Windows uses CRLF (\r\n, two characters) as a line ending. Unix/macOS use LF (\n, one character). Some tools count lines by counting LF characters only, so a Windows file pasted into a Mac tool may count differently. This tool handles both line ending styles and gives an accurate count regardless of which you use.
What is the average line length stat useful for?
Average line length is most useful for code quality — style guides for Python, JavaScript, and most languages recommend keeping lines under 80 or 100 characters. An average well above 80 suggests your code has long lines that may need wrapping. For prose, average line length is less meaningful because natural language wraps differently depending on font and window size.
What is the longest line stat?
The longest line shows the character count of the widest line in your input, along with a truncated preview of that line. For code: this quickly identifies lines that violate line-length linting rules. For data exports (CSV, TSV): a very long line might indicate a field that contains an unexpected newline or an unescaped delimiter, which breaks parsers.
Can I use this to count lines in a large log file?
Yes, within browser memory limits. You can paste text up to a few megabytes directly into the textarea and get an accurate line count instantly. For very large files (10MB+), pasting into a browser textarea may be slow — for those cases a command-line tool like wc -l is more appropriate.
Tools you might like
17 tools across three categories — all free, no signup required.
Measure, analyze, and optimize your writing. Count words, estimate reading time, check readability scores, and find which keywords dominate your draft.
Transform and clean text into the format you actually need. Convert case, strip junk whitespace, remove duplicate lines, and generate filler copy in seconds.
Built for code and data work. Convert identifiers between naming conventions, inspect byte counts, strip HTML tags, count lines, and deduplicate with a diff view.