Line Counter
A free tool by DeepRit, a Google Ads agency that does PPC and nothing else. We build and run Google Ads accounts so every click is accounted for. Book a free audit call
Free line counter. Count the lines in any text, with non-empty and blank lines, duplicate lines and the longest, shortest and average line length.
- Total lines
- 0
- Lines with text
- 0
- Blank lines
- 0
- Repeated lines
- 0
- Longest line (characters)
- 0
- Shortest line
- 0
- Average length
- 0
Free, no sign-up. Runs in your browser: nothing you type is uploaded or saved.
How to use the line counter
- Paste your text into the box: code, a list, a CSV file, a poem, a log or any other text.
- Read the counts, which update as you type:
- Total lines, including blank ones.
- Lines with text.
- Blank lines.
- Repeated lines: how many lines are exact duplicates of an earlier line.
- Longest line, shortest line and average length, in characters (counting only lines with text).
The line counter runs in your browser, so your text never leaves your device.
How lines are counted
A new line starts at every line break. The line counter recognises all common line endings: Windows (CRLF), Unix and macOS (LF), and old Mac (CR), so text copied from any system counts correctly.
A few details:
- Blank lines are lines with nothing on them, or only spaces and tabs.
- A trailing line break at the end of the text creates one final empty line, which is counted as a blank line. Many editors add one automatically.
- Wrapped lines don't count as separate lines. If a long line wraps on screen, it's still one line; only actual line breaks start a new one.
- Line length counts characters, including spaces, with emoji and accented letters counting as one character each.
Why count lines?
- Lists and data: how many items, addresses or records are in a list, or how many rows in a CSV export (remember that a header row counts as a line).
- Code: the length of a file or function. Lines of code is a rough measure of size, though not of quality or effort.
- Logs: how many entries or errors were recorded.
- Poetry and lyrics: the number of lines in a poem, verse or song, such as the 14 lines of a sonnet.
- Subtitles and scripts: checking line counts against limits.
- Data checks: comparing line counts before and after a cleanup or import to make sure nothing was lost.
- Text limits: some forms, platforms and apps limit the number of lines.
Finding duplicate lines
The "Repeated lines" count shows how many lines are exact copies of an earlier line. If it's above zero, your list has duplicates. The remove duplicate lines tool removes them, keeping the first copy, and the sort lines tool sorts lines so duplicates sit together.
Line length
The longest line helps with:
- Code style: many style guides limit line length (often around 80 to 120 characters) to keep code readable.
- SMS and messaging: the SMS character counter checks message length and segments.
- Fixed-width data and email: some older systems and plain-text emails wrap at around 72 to 80 characters.
- Spotting problems: an unusually long line in a CSV file may mean a missing line break or merged records.
Other counting tools
- Words and characters: the word counter counts words, characters, sentences and paragraphs, and the character counter counts characters with and without spaces.
- Numbering lines: the add line numbers tool numbers every line, useful for referencing specific lines.
- Joining lines: the remove line breaks tool turns lines back into paragraphs.
Counting lines in other tools
- Code editors usually show the line count in the margin or status bar.
- Command line: on Linux and macOS,
wc -l file.txtcounts newline characters, which may be one less than the line counter here if the file doesn't end with a line break. - Spreadsheets:
=ROWS(A1:A100)or=COUNTA(A:A)counts rows or filled cells.
Small differences between tools usually come from how they treat the last line and blank lines.
Counting lines in CSV files and data
CSV files and other data exports store one record per line, so a line counter is a quick way to check how many records you have. A few things to remember:
- The header row counts as a line. A CSV with 1,000 records and a header row has 1,001 lines.
- Blank lines at the end are common and usually harmless, but some import tools treat them as empty records.
- Line breaks inside quoted fields are allowed in CSV, so a record with a multi-line address can span several lines. In that case, the line count is higher than the record count. The CSV to JSON converter parses CSV properly, including quoted line breaks.
Comparing line counts before and after cleaning or converting data is a simple way to catch lost or duplicated records.
Counting lines of code
Lines of code (LOC) is a rough measure of the size of a program. The line counter counts every line, including blank lines and comments. Developers sometimes distinguish:
- Physical lines: every line in the file, which is what this tool counts.
- Source lines of code (SLOC): lines that contain code, excluding blanks and comment-only lines.
The "Lines with text" figure gives a quick approximation of non-blank lines. Lines of code isn't a good measure of productivity or quality: shorter, clearer code is usually better than more of it. But it's useful for estimating the size of a file or comparing versions.
Line limits on platforms and forms
Some places limit the number of lines rather than characters:
- Address fields often allow a set number of lines.
- Some social media bios display only a few lines before truncating.
- SMS and push notifications are usually limited by characters; the SMS character counter checks those.
- Subtitles are typically limited to two lines on screen at once.
The line counter shows both the number of lines and the longest line, so you can check both kinds of limit.
Poems, lyrics and scripts
For creative writing, line counts help with form:
- Haiku: 3 lines.
- Limerick: 5 lines.
- Sonnet: 14 lines.
- Villanelle: 19 lines.
Song lyrics and scripts also have typical line counts per verse or scene. Paste a draft into the line counter to check structure quickly, and use add line numbers to reference specific lines when sharing feedback.
Why line counts sometimes disagree
If the line counter and another tool show different numbers, the usual reasons are:
- A trailing line break: some tools count the empty line after it, some don't.
- Different line endings: text from Windows (CRLF) and Unix (LF) can be counted differently by older tools.
- Wrapped lines: word processors show wrapped lines, but they aren't real line breaks.
The line counter recognises all line-ending styles and counts only real line breaks.
Quick tip
To count only the lines that contain a particular word, paste your text into the find and replace tool or filter it in a spreadsheet first, then paste the filtered lines into the line counter.
Who uses a line counter
Developers use it to check file and snippet sizes. Data analysts use it to count records in exports. Writers and poets use it to check structure, and marketers use it to count items in lists before importing them.
In summary
Paste your text to see total lines, lines with text, blank lines, repeated lines and line lengths at a glance. It's a quick way to check lists, data files, code and creative writing, and to confirm that nothing was lost during clean-up or conversion.
A worked example
A marketing assistant has exported a list of newsletter subscribers from an old system and pastes it into the line counter before importing it into a new email platform:
- Total lines: 1,204.
- Lines with text: 1,200.
- Blank lines: 4.
- Repeated lines: 37.
- Longest line: 64 characters.
Thirty-seven duplicates and four blank lines need removing, so she runs the list through the remove duplicate lines tool and pastes the result back. The line counter now shows 1,163 lines with text and no repeats: the number she expects to see after the import.
Need more customers from Google?
This tool is free and runs in your browser. If your business also needs more leads or sales, Google Ads is where people search with their wallet out. DeepRit manages Google Ads for small and mid-size businesses, and only Google Ads. We check your account before we ever get on a call, then fix the structure, the keywords, the tracking and the ads, with month-to-month terms and no long contract. Book a free audit call.
Sources and further reading
- Newline on Wikipedia: the different line-ending conventions (CRLF, LF and CR) and why line counts can differ between tools.
Frequently asked questions
How do I count the lines in a text?
Paste it into the line counter. It shows total lines, lines with text and blank lines straight away.
Does the line counter count blank lines?
Yes. It shows total lines, and separately how many are blank and how many contain text.
Why does my editor show a different number of lines?
Tools treat a final line break and blank lines differently. A trailing line break adds one empty line here.
Can it find duplicate lines?
Yes. "Repeated lines" counts exact duplicates. Use the remove duplicate lines tool to delete them.
Do wrapped lines count as separate lines?
No. Only real line breaks start a new line.
Is the line counter free?
Yes. It's free, needs no sign-up, and your text stays in your browser.
Free PPC audit
See where your ad budget leaks.
We look at your Google Ads account before the call, then walk you through what we'd fix first, in dollars. No obligation, no hard sell.