Free Line Counter

Paste your text below and this line counter shows how many lines it has: total, empty, whitespace-only and unique, plus the average, longest and shortest line length. It is free, needs no sign-up and runs in your browser, so nothing is uploaded.

0 lines

Total Lines
0
Non-Empty
0
Empty Lines
0
Avg Length
0.0

Detailed Line Statistics

Total Lines
0
Non-Empty Lines (incl. whitespace-only)
0
Empty Lines
0
Whitespace-Only Lines
0
Average Line Length
0.00 chars
Unique Line Count
0

Note: All counting happens in your browser. Your text is never sent to any server. Every line break starts a new line, so text that ends with a line break has an empty last line (as in code editors). Line lengths count characters as you see them: an emoji or an accented letter counts as one. Empty lines have zero characters; whitespace-only lines contain only spaces, tabs or other whitespace.

Summary: count lines online, free and private

A line counter tells you how many lines a text has. To count lines free and privately, paste your text into the box above: the Total Lines card updates as you type, and nothing is uploaded (check the Network tab in your browser's DevTools).

Every line break starts a new line, whether it is Windows (CRLF), Unix (LF) or classic Mac (CR). It also separates empty from whitespace-only lines, counts unique lines and reports average, longest and shortest line length. For non-empty LF or CRLF text it reports one more than wc -l, which counts line feeds. For words or characters instead, use the word counter or the character counter.

Table of Use: what to paste and which number to read

TaskWhat to pasteWhere to read the answer
Check how many records an export holdsCSV, TSV or log textTotal Lines, minus 1 for a header row, minus 1 more if the text ends with a line break
Find stray blank lines in a config file.env, YAML or INI contentsEmpty Lines and Whitespace-Only Lines
Check a style-guide line limitSource codeLongest Line card: line number and length
Spot duplicates in a listOne item per lineUnique Line Count compared with Total Lines
Count verses and stanza breaksA poem or song textNon-Empty Lines for lines of verse; Empty Lines for stanza breaks
Jump to line 214 from an error messageA script or log excerptType 214 in Go to line number, then click Go

Tiny inputs show how the counts behave (โ†ต is a line break, โฃ is a space). Unique Line Count compares lines exactly, so case and trailing spaces matter and a blank line counts as one value.

InputTotalEmptyWhitespace-onlyUnique
(nothing)0000
oneโ†ต2102
aโ†ตโ†ตb3103
aโ†ตโฃโฃโ†ตa3012

Features

  • Eight statistics. Total Lines, Non-Empty, Empty, Whitespace-Only, Unique Line Count, Average Line Length, the Longest Line and the Shortest Non-Empty Line.
  • Characters as you see them. An emoji or an accented letter counts as one character, and the line break itself is never counted.
  • Line numbers. The Show line numbers checkbox adds a numbered gutter. While it is on, long lines scroll sideways, so each number matches one line.
  • Go to line number. Enter a whole number from 1 to the last line and click Go: the line is selected, scrolled into view and highlighted in the gutter while Show line numbers is on. A number out of range shows an error.
  • Copy Statistics and Download Report. Copy a plain-text summary, or save line-counter-report.txt with a line-by-line breakdown marking empty and whitespace-only lines.
  • Private. No account, no upload, no stored text. On very large pastes the statistics may lag your typing slightly.

After counting, you can remove empty lines, remove duplicate lines, sort the lines alphabetically, or add line numbers to the text.

How to Use the Line Counter

  1. Type or paste your text into the box labelled "Enter or paste your text".
  2. Read the cards under the box: Total Lines, Non-Empty, Empty Lines and Avg Length.
  3. Scroll to Detailed Line Statistics for Whitespace-Only Lines and Unique Line Count.
  4. Scroll to Line Length Analysis for the Longest Line and the Shortest Non-Empty Line.
  5. Tick or untick Show line numbers, then use Go to line number and Go to jump to a line.
  6. Click Copy Statistics or Download Report to keep the results, and Clear to start over.

Who Can Use a Line Counter

Developers and sysadmins check how long a script, log or config file is and locate the line an error points to; the regex tester and find and replace help when a pattern is the problem. Data teams confirm an export has the expected rows before importing it, for example after the CSV to JSON converter. Writers and students count verses or list items, and the text diff tool compares two versions line by line.

FAQs

How do I count lines in text online for free?

Paste or type your text into the box labelled "Enter or paste your text". The Total Lines card shows the count straight away, and empty, whitespace-only and unique lines appear under Detailed Line Statistics. There is no sign-up and your text stays in your browser.

Why does the line count differ from wc -l?

The Unix command wc -l counts line feeds, not lines, so for non-empty LF or CRLF text this tool reports one more. If your text ends with a line break, the extra line is the empty last line shown here; if it does not, wc -l misses the last line. wc -l also ignores old Mac CR-only breaks, which this tool counts.

Does the line count include blank lines?

Yes. Total Lines counts every line, blank or not. Empty Lines have zero characters; Whitespace-Only Lines hold only spaces, tabs or other whitespace and are also counted in Non-Empty. To count only lines with visible text, subtract Whitespace-Only Lines from Non-Empty Lines.

How do I find the longest line in a text?

Scroll to Line Length Analysis after pasting. The Longest Line card shows its line number, its length and a preview. Length counts characters as a reader sees them, so an emoji or an accented letter is one character, and the line break is not counted. Ties go to the first line, and empty lines are never picked.

Can I count lines of code with it?

You can count physical lines: Total Lines is every line, and Empty plus Whitespace-Only Lines show how many are blank. The tool does not recognise comments or syntax, so it cannot report true source lines of code. The Longest Line card's length tells you whether any line goes past 79 characters (PEP 8) or 80 (Prettier's default), and its line number shows where.

Is it safe to paste code, logs or private text into a line counter?

Counting runs in your browser with JavaScript and nothing is uploaded: the Network tab in your browser's DevTools shows no request when you type or paste. The text is not saved, so it is gone when you close or reload the page. The downloaded report is created on your own device.

Why is a wrapped sentence counted as one line?

A line here ends at a line break you typed or pasted, not where the screen wraps text, so resizing the window never changes the count. A sentence that fills three rows is still one line; word processors usually count wrapped rows.