Line Counter
Count total, non-empty, and blank lines, measure your longest, shortest, and average line length, and add line numbers to any text. Live and 100% in your browser.
- Free, no account
- No watermark
- No usage limit
About the Line Counter
Most line counters hand you one number and stop, but this one goes further. Paste your text and you get the count broken out the way it actually matters, the total, the lines that have real content, and the blank ones, and then the part almost no free counter bothers with: how long your lines actually are. You get the longest, the shortest and the average, and the two extremes come with their line numbers so you can jump straight to them. Turn on line numbering and it prefixes every line with its number, ready to copy or download. It all runs live as you type, entirely in your browser. Nothing is uploaded, nothing is stored, and there's no size cap. A six-line note or a 50,000-line log both count the same way, instantly.
Find the line that's actually too long
This is the problem that sends most developers to a line counter, and the one a plain counter can't help with. Your linter fails the build because a line is over 120 characters, and now you're scrolling a file squinting for it, and a total-line count does nothing to help. So this tool measures every line and reports the longest one with its number, something like line 42 at 137 characters, and you go straight there instead of hunting. That is the difference between a counter and an analyzer, and it's the whole reason we built the length stats in.
The average line length is a fast read on a whole file. A high average usually means dense, wrapping paragraphs that want breaking up. The shortest non-empty line catches the stray one-character row you left behind by accident. Length is measured in characters and does not count the line break itself, which is exactly what a "keep lines under 80" or "max 100 chars" rule is checking against.
Add line numbers, then copy or download
Sometimes you don't want a count, you want the text back with every line numbered. You're reviewing a config with a coworker in chat and need to say "change line 14." You're quoting a snippet in a bug report. Flip on Add line numbers and every line gets its number, and you copy the whole block or download it as a plain .txt file.
The numbers right-align by default, so 9, 10, and 100 stack cleanly down the left edge instead of jittering. You pick the separator to match wherever you're pasting, a colon, a dot, a pipe, or a tab. Working against an array or an editor that starts counting at 0? One checkbox makes the numbering zero-based. And it numbers exactly the lines this tool counts, so the numbered output and the stat cards can never disagree with each other.
How to use
- Type, paste, or drop a file into the box. Drag a .txt, .log, or .csv straight in, or hit Choose a text file to browse. It's all read on your own device, and the counts update on every keystroke, no button.
- Read the top row of stats. Total, non-empty, and blank lines on the left, then longest, shortest, and average line length on the right, plus words and characters.
- Check the longest-line number if you're chasing a width limit, then jump to that line in your editor.
- Set the trailing-newline rule with the checkbox below the box if your text ends in a line break and the count looks off by one.
- Turn on line numbering when you want the numbered text itself, tweak the separator and alignment, then Copy numbered or Download .txt.
Total, non-empty, and blank: three numbers, three jobs
Most counters give you one number, and it's usually the one that fails you first, because "lines" means different things depending on the job. Total lines is every line, content or not, the number an editor's status bar shows. Non-empty lines strips the blanks, and it's the count that matters when each line is supposed to be a real thing, a name, a data row, an email you're about to import. Twelve lines with two blank separators means ten actual entries. Blank lines is the difference, and it's the one that catches problems, an unexpected blank means a stray double-Enter or an empty row that'll break an import.
A blank line here isn't only a truly empty one. A line of nothing but spaces or tabs counts as blank too, because you can't see the difference and neither can your reader. Naive counters miss that and mark it as content. This one trims first, so a whitespace-only line lands in the blank count where it belongs.
The trailing-newline question, and why there's a checkbox
Take x followed by a single newline. How many lines is that? You can defend either answer. One line, because the newline just ends the content, the way a proper text file's last line does, and wc -l reports 1. Or two, because splitting that string on the newline gives ["x", ""], which plenty of web tools count as two.
Neither is wrong, they answer different questions. This tool defaults to the "one line" reading, so a 100-row file that ends cleanly with a newline is 100 lines, not 101. That matches wc -l, most editors, and how people think about their data. The checkbox flips it to the naive split, which helps when you're debugging why your own code reports a different number and want to see its answer. That setting only affects the final break, and blank lines inside the text count either way.
Windows, Mac, and Unix line endings count the same here
Line breaks aren't one character. Unix and macOS use a single line feed, Windows uses a carriage return plus a line feed (two characters for one break), and old classic Mac used a lone carriage return that still turns up in exported files. A counter that only knows the Unix break miscounts Windows text and leaves a stray carriage return on every line, which throws off the non-empty check.
This tool normalizes all three before counting, so the same text gives the same number wherever it came from. Copy a list from Notepad, from a Mac terminal, or from a diff on GitHub, and the count holds. That's what simple counters get wrong the moment real pasted text shows up.
Frequently asked questions
How do I find which line is too long for my linter?
Read the Longest line stat. It shows the character length of your widest line and the line number it sits on, so you open your editor, jump to that line, and fix it instead of scanning the file. Length counts characters without the line break, which is what most max-length rules measure.
Does the tool number every line, or only the ones with content?
Every line, blanks included, the same way an editor numbers a file. If numbering skipped blanks, line 14 in the tool wouldn't match line 14 in your editor, which defeats the point of quoting a number to someone. When you only care about lines that hold content, read the Non-empty lines stat instead.
Does "longest line" count a line that's only spaces?
Yes. Length counts every character, spaces and tabs included, because a line padded with 200 spaces genuinely is 200 wide and can blow a limit. Shortest is the exception, it skips blank and whitespace-only lines and reports the shortest line with real content.
Why does another tool give me a different line count?
Almost always one of three things. It counts the final newline as an extra empty line (flip the checkbox to match). It mishandles Windows versus Unix endings, which this tool normalizes and many don't. Or it treats a line of spaces as content when this tool calls it blank. Match the settings and the numbers agree.
Can I count a big log file without pasting it?
Drop it onto the box, or use Choose a text file to pick one. It's read locally in your browser and never sent anywhere, so it's fine for a private log or client data. No size cap either, though a huge file might pause a fraction of a second while it recounts, and none of it gets truncated on the way.
My text shows on six rows but says one line. Is that a bug?
No, that's word wrap. One long line folded to fit the box, and wrapping is purely visual, it adds no line breaks. Resize the box and the rows rearrange while the count holds. A line is defined by real break characters, not by where the display happens to fold. Six real lines need six Enter presses.
Is my text uploaded or saved anywhere?
Never. Splitting, counting, numbering, all of it happens in your browser on your own device. Nothing is sent to a server, stored, or logged, and there's nothing to sign up for. Close the tab and it's gone.
How is this different from a word or character counter?
Different units. A word counter totals words and reading time. A character counter is about hard caps like a 280-character post or a 160-character meta description. A sentence counter is about prose structure. This one is about lines, rows, records, list items, and lines of code.