Line Counter & File Stats

Count the lines, words, characters and bytes in text or a file of any size, the way wc does and the way your editor does. Finds blank, duplicate and over-long lines, the longest line, the line-ending type (LF, CRLF, CR or mixed) and a byte order mark.

Tool Text & Encoding Updated Oct 15, 2026
How to Use
  1. Paste or type text in the box, or drop a file on it (or use Open file). Files of any size work: a 200 MB log is read in pieces while the counts climb.
  2. Read the four main counts under the chart. Lines counts a last line even when it has no line break; the table also gives the wc -l number and the line numbers an editor shows.
  3. Press Show next to the longest or shortest line to jump to it, and check the line-ending, BOM, duplicate and trailing-space rows for problems.
  4. To see real line endings, open the file instead of pasting it: browsers turn every pasted line break into LF.
  5. Try a preset to see how CRLF, CR-only, mixed endings and a BOM change the numbers, then read Show Work for how each count was made.
Input
paste, type or drop a file
Presets
Line Lengths & Counts
Paste text or drop a file to see its line-length profile and every count.
Lines
0
Words
0
Characters
0
Bytes
0

Worked Example

Carl Sandburg’s “Fog” (1916), pasted with no line break after the last line. It has 6 line breaks. The last line, “and then moves on.”, has no break after it, so it is counted as well: 7 lines. wc -l counts only the 6 newline characters and prints 6; an editor numbers the lines 1 to 7.

Line 3 is empty, so there are 1 blank and 6 non-blank lines. The seven lines hold 13 + 19 + 0 + 15 + 20 + 18 + 18 = 103 characters, plus the 6 line breaks = 109 characters, and since all are ASCII, 109 bytes. The longest line is line 5, “over harbor and city”, at 20 characters; the average is 103 ÷ 7 = 14.7 characters per line. There are 21 words: runs of characters between spaces or line breaks.

A small CSV file written for Excel on Windows: four rows ending in CRLF, starting with a byte order mark. That is 4 lines and wc -l agrees (4), because every row ends with a line break. The text is 60 characters of data plus 4 × 2 for the CRLF pairs = 68 characters, but é, ã and ü take 2 bytes each in UTF-8 and the BOM adds 3, so the file is 68 + 3 + 3 = 74 bytes.

The common mistake: pasting to check line endings. A browser text box turns every CRLF and CR into LF the moment text is pasted, so pasted text always looks like LF. Open the file instead; it is read byte for byte. A file from a classic Mac uses CR alone, so wc -l prints 0 for it however many lines it has.

Show Work

Paste text or open a file to see how each count is made.

Definitions

A line (POSIX)
0+ characters + \n
Text after the last \n is an “incomplete line”
wc -l
n = count of \n
CR-only line endings count 0
Lines (this tool)
L = breaks + (last line unterminated ? 1 : 0)
A break is CRLF, LF or CR
Editor line numbers
1 … breaks + 1
The cursor line after a final break is shown too
UTF-8 bytes per character
1 · 2 · 3 · 4
U+0000–007F · U+0080–07FF · U+0800–FFFF · U+10000–10FFFF (RFC 3629)
UTF-16 units
code points + (count above U+FFFF)
What JavaScript’s .length and HTML maxlength count
Average line length
Σ line lengths ÷ L
Line endings are not part of a line’s length
Duplicate lines
L − distinct lines
Same as wc -l minus sort -u | wc -l, for a file with a final newline

Why wc and Your Editor Disagree

wc is one of the oldest Unix commands. It is in the first edition of the Unix Programmer’s Manual, dated 3 November 1971, with Joe Ossanna (“jfo”) listed as its owner. That first version was a “word count” for documents: it counted words, text lines, and the lines beginning with “.” that held formatting commands for the roff typesetter. Today’s wc prints newlines, words and bytes by default; POSIX added -m for characters, because a byte is no longer always a character, and GNU’s version adds -L for the width of the longest line.

POSIX defines a line as “a sequence of zero or more non-<newline> characters plus a terminating <newline> character”, and the text after the last newline as an “incomplete line”. In Unix the newline ends a line rather than separating two lines, so every complete line carries its own newline. That is why cat a.txt b.txt joins the last line of a.txt onto the first line of b.txt when a.txt has no final newline, why diff prints “\ No newline at end of file”, and why the C standard leaves it to each system whether the last line of a text stream needs one. wc -l follows the definition exactly: it counts newline characters.

Editors count what they draw. Most treat any of CRLF, LF and CR as a line break and give every displayed line a number, so a file without a final newline still has its last line numbered, and a file with one shows an empty numbered line after it for the cursor. CRLF goes back to Teletype terminals, which needed a carriage return and a line feed to start a new line; Unix kept only LF, and classic Mac OS used CR alone. A CR-only file is a single “line” to wc.

About This Tool

This tool is wc with the answers it leaves out. It counts lines three ways (complete and incomplete lines, wc -l’s newline count, and an editor’s line numbers), words, characters as code points and as UTF-16 units, and bytes, then the blank, non-blank, duplicate, over-80-character and trailing-whitespace lines, the longest and shortest lines with a jump to each, the average line length, the indentation style, the line-ending type with a count of each kind, and any byte order mark.

Files are read straight from your disk in slices and decoded as UTF-8 (or UTF-16 when the file starts with a UTF-16 byte order mark), so very large files work and the counts climb as the file is read. Everything runs in your browser; nothing you paste or open is uploaded.

For limits on posts, text messages and meta descriptions, use the Character Counter; to change line endings or remove a BOM, use the converters below.

Related tools: Character Counter, EOL (Line Ending) Converter, Text Cleaner, and BOM Adder / Remover.

Frequently Asked Questions

Why does wc -l give one fewer line than my editor?

wc -l counts newline characters, not lines. If the last line has no newline after it, wc does not count it, so a file whose last line is “done” with no line break shows one fewer. Editors number the lines they display, and many also show an empty last line after a final newline, so an editor can show one more. This tool gives all three numbers.

Does the last line count if it has no newline?

Here, yes: Lines is the number of line breaks plus one if text follows the last break. POSIX calls such a line an “incomplete line”, and wc -l leaves it out. A text that ends with a line break gets nothing extra: “a↵b↵” is 2 lines, and so is “a↵b”.

Can it count lines in a very large file?

Yes. The file is read from your disk in 2 MB pieces and decoded as a stream, so the whole file is never held in memory, and the counts update as it goes. A 200 MB file takes a few seconds. Nothing is uploaded. Only the duplicate-line count has a limit: it stops tracking after 1,000,000 different lines.

Why is the byte count bigger than the character count?

UTF-8 uses 1 byte for ASCII but 2 for letters such as é and ü, 3 for most other characters (中, あ) and 4 for emoji. A Windows line ending (CRLF) is 2 characters, and a UTF-8 byte order mark adds 3 bytes at the start. For a file, the byte count is its real size on disk.

What counts as a blank or duplicate line?

A blank line has nothing but spaces or tabs, or nothing at all (POSIX calls the second kind an empty line). A duplicate is a line whose text exactly matches an earlier line, like sort | uniq -d would find: case and spaces matter, but the line ending does not.

How do I use the Line Counter & File Stats?

Simply type your numbers and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.

Is it free? Does it work without internet?

Yes to both. It is free with no sign-up, and once the page has loaded it keeps working even with no internet.

Where does my data go?

Nowhere — every calculation runs on your own device. Nothing you enter is uploaded, logged, or stored.

Common Use Cases

Checking a CSV before import

A header plus 1,000 records is 1,001 lines. If the export has no final newline, wc -l prints 1,000 and a script that trusts it drops a row. The table shows both numbers and whether the file ends with a line break.

Logs and data dumps

Drop a 200 MB log to get its line count, the number of distinct lines and the most repeated line, for example one error message logged 4,812 times.

Code style checks

See how many lines are over 80 characters, which line is longest, how many have trailing spaces and whether indentation mixes tabs and spaces.

Line-ending problems

A script that fails with “bad interpreter” or a diff where every line changed usually means CRLF where LF was expected, or a mix of both. The line-ending row counts each kind.

CSV files for Excel

CSV files made for Excel often start with a 3-byte UTF-8 byte order mark (EF BB BF) so the accents survive, and Windows programs end each row with CRLF. The BOM row shows it, and the byte count includes its 3 bytes.

Last updated: