esc
No tool matches that yet.
  1. Home
  2. Text & unicode
  3. Line counter

Line counter

Paste any list, log or source file — or open one. See how many lines, blanks, duplicates and lines of code it has, then filter, trim, dedupe, sort, number or wrap every line and copy the result.

Paste a list, a log or source code — or open a file
0lines
0non-empty lines
0blank lines
0unique lines
0duplicate lines
0words
0characters
0max line length
Clean
Order
Add

Type \t for a tab in any of these fields.

Tick an option above — the output updates instantly.

Line details

Windows (CRLF), Mac and Linux (LF) line endings are all understood. Files are read on your device — nothing is uploaded.A trailing line break doesn't count as an extra line

How to use the line counter

Paste text into Input — or press Open file, or drop a file on the box, for a .txt, .csv, .log or source file — and the bar at the top counts it immediately: total lines, non-empty lines, blank lines, unique lines, duplicate lines, words, characters and the length of the longest line. The duplicates tile turns amber when the list contains repeats. Its figures follow the Trim and Case-sensitive settings, and its label says so, so the tiles always agree with what Remove duplicates will do.

The options — Clean, Order and Add — transform a copy of the list into Output, live, without touching what you pasted. The sentence under the boxes reports exactly what happened: “1,204 lines out of 1,380 — trimmed 12 lines, removed 41 blank lines, removed 135 duplicates, sorted A → Z”. Copy or download the result, or press Use as input for another pass. Line details lists every line with its number, length and word count, and exports the lot as CSV. Your options are remembered; your list is only kept if you tick Remember my list in this browser.

Very large files — over 25 MB, such as a server log — are counted as a stream straight from disk rather than loaded into the page, giving line, blank-line, word and longest-line figures in seconds. For joining lines into a paragraph, use remove line breaks; to count how often each word appears, use the word frequency counter.

Counting lines of code

Tick Count lines of code and the tool classifies every line the way code-metrics tools such as cloc do: a code line has at least one character that isn’t whitespace or comment; a comment line holds only a comment; a blank line holds nothing. A line with code and a trailing comment counts as code, and the tool tells you how many of those there are. The comment share shows how documented the file is.

FamilyLanguagesComments recognised
C-styleJavaScript, TypeScript, C, C++, C#, Java, Go, Rust, Swift, Kotlin, PHP// and /* … */
PythonPython#, and docstrings in triple quotes
# commentsShell, Ruby, Perl, R, YAML, TOML, PowerShell#, =begin … =end, <# … #>
-- commentsSQL, Lua--, /* … */, --[[ … ]]
MarkupHTML, XML, Markdown, SVG<!-- … -->
StylesheetsCSS, SCSS, Less/* … */, and // in SCSS and Less

Comment markers inside quoted strings — "http://…", '# not a comment', template literals — are ignored, which is where simpler counters go wrong. The language is taken from the file extension when you open a file, otherwise detected from the text; pick it yourself if the guess is wrong. A regular expression containing a quote mark can confuse the scanner for the rest of that line only.

The order options are applied in

When several options are ticked they always run in the same sequence, so the output is predictable:

  1. Trim removes spaces and tabs from both ends of each line.
  2. Keep or remove lines containing a word or phrase — or a regular expression, with or without match case — filters the list. Blank lines are dropped when keeping and left alone when removing.
  3. Remove blank lines drops lines that are empty or contain only whitespace.
  4. Remove duplicates keeps the first occurrence of each line and drops later repeats. Case-sensitive is on by default; untick it and Apple, APPLE and apple count as one, with the first spelling kept.
  5. Sort, then reverse, then shuffle.
  6. Numbers, prefix and suffix are added last, so they never affect sorting or duplicate detection. Type \t in the prefix, suffix or After number field for a tab.

Because trimming runs before deduplication, apple and apple   only count as duplicates when Trim is ticked — the most common reason a “remove duplicates” tool appears to miss some. Invisible characters such as non-breaking spaces and zero-width spaces pasted from web pages can have the same effect.

Sorting: alphabetical, natural and by length

SortResult for: item 10, Item 2, éclair, appleUse it for
A → Zapple, éclair, item 10, Item 2Names, words, general lists
Naturalapple, éclair, Item 2, item 10File names, versions, numbered items
Lengthapple, Item 2, éclair, item 10Finding outliers, tidying code

Alphabetical sorting uses your browser’s language rules, so accented letters sort with their base letter and capitals sit with lower case. Natural sorting reads runs of digits as numbers, so file2 comes before file10. Every sort is stable: equal lines keep their original relative order. Lists of more than 150,000 lines fall back to a faster character-by-character alphabetical sort.

Shuffle uses the browser’s cryptographic random generator and keeps its order while you adjust other options; press Shuffle again for a new one. For drawing random winners, the random number generator is built for that job.

How lines are counted

A line is everything between two line breaks. Windows files use CRLF (\r\n) and Mac, Linux and the web use LF (\n); both are read correctly, and a mixture is normalised. A single line break at the very end of the text does not create an extra, empty line — most editors and the Unix wc -l command disagree by exactly one on this, and ours matches what you see. Blank lines are empty or contain only spaces and tabs.

Output uses LF by default. Choose CRLF for an old Windows tool or a CSV importer that expects it. Characters are counted as user-perceived characters, so an emoji or an accented letter is one; the streamed count for very large files reports UTF-16 units instead.

Frequently asked questions

How do I remove duplicate lines but ignore upper and lower case?

Tick Remove duplicate lines, then untick Case-sensitive. Lines that differ only in capitalisation are treated as the same and only the first one is kept, with its original spelling. Tick Trim as well if some lines may have stray spaces at the ends. The unique and duplicate tiles at the top follow the same settings.

How do I count lines of code without comments and blank lines?

Paste your code or open the file and tick Count lines of code. The tiles split the file into code, comment and blank lines, with the language detected from the extension or content. Comment markers inside strings are ignored, Python docstrings count as comments, and a line with code plus a trailing comment counts as code, matching tools such as cloc.

Why doesn't my line count match my text editor?

Usually because of a trailing line break. If your text ends with a newline, some editors show an extra empty line and wc -l counts differently; we do not count that final empty line. Line wrapping also matters: an editor with word wrap shows one long line across several rows, but it is still one line here.

Is there a limit to how many lines I can paste?

There is no fixed limit. Lists of a few hundred thousand lines count and clean in well under a second on a typical laptop. Files over 25 MB are counted as a stream without loading them into the page, so even multi-gigabyte logs give a line count, though cleaning tools need smaller files. Nothing is uploaded.

How do I delete every line that contains a certain word?

Type the word or phrase into the box under Trim and leave the menu on Remove lines containing. Switch to Keep only lines containing to do the opposite, such as pulling every error line out of a log. Tick Match case for exact capitals, or Regex for patterns like ^ERROR|WARN.

How do I number lines starting from zero or with leading zeros?

Tick Number lines, set Start at to 0 (or any number, including negatives), and choose Zeros under Padding to get 001, 002 and so on. The After number field sets what follows each number: a full stop and space by default, or type \t for a tab, a colon or a closing bracket. Blank lines are skipped unless you untick that option.

Text & unicode