About this line counter
Use this counter to check how many lines a poem, a list, a CSV file, or a source file has. Choose All lines for the plain total, Non-blank lines to skip empty lines, or Code lines to measure lines of code without comments and blank lines. Comment lines are recognized for the most common languages: # for Python, Ruby, and shell scripts, // for JavaScript, Java, and C, -- for SQL and Lua, % for LaTeX, ; for INI files, and block comments between /* and */ or <!-- and -->. The numbered preview marks every line as content, comment, or blank, so you can see exactly what was counted.
How to use this line counter
- Add your text. Type, paste, or press an example. An example only fills the box; it does not count yet.
- Choose what to count. Pick All lines, Non-blank lines only, or Code lines in the Count menu.
- Press Count lines. The line count for your choice appears first, followed by line and text statistics, the longest and shortest lines, and the numbered preview.
- Copy the result. Press Copy count to paste the number elsewhere, or change the text or the menu and press Count lines again.
Frequently asked questions
Does a line break at the end of the text add a line?
Yes. A final line break starts a new, empty line, the same way a text editor shows it. That line counts in All lines and as a blank line, but not in Non-blank lines or Code lines.
Which lines count as blank?
A line that is empty or contains only spaces and tabs. Blank lines are also what separate paragraphs in the Paragraphs total.
How are comment lines detected?
A line is a comment when its first non-space characters are #, //, --, %, or ;, or when it sits inside a /* … */ or <!-- … --> block. A comment after code on the same line, such as x = 1 # note, leaves the line counted as code.
Will Markdown headings be counted as comments?
Yes, a line starting with # is treated as a comment, so headings in Markdown count as comment lines. Use All lines or Non-blank lines for Markdown and prose; the Code lines mode is meant for source code.
Do Windows line breaks count differently?
No. Windows (CR + LF) and old Mac (CR) line breaks are converted to a single line break first, so the count is the same wherever the text came from.
How are line length and the longest line measured?
Length is the number of characters as they appear on screen, including spaces. Averages, the longest line, and the shortest line only look at lines that are not blank.