Code Line Counter
Count total, blank, non-blank, and comment lines in any pasted code.
Paste your code below - this tool counts total, blank, non-blank, and (optionally) comment lines.
More Programming Language Tools
View all 23Comment-line detection uses common single-line comment markers (//, #, --) - it's a reasonable approximation, not a full language-aware parser.
What Does This Tool Count?
Total line count, blank lines, non-blank lines, and (based on common comment markers like //, #, or --) an estimate of comment-only lines.
Why Use This Tool?
A quick, practical way to gauge a file's size or estimate how much of it is actual code versus comments/whitespace, without needing to open it in an IDE with a line-count feature.
How to Use It
- Paste your code.
- Click Count.
- Review the total/blank/non-blank/comment line breakdown.
Limitations
Comment detection looks for common single-line comment markers at the start of a trimmed line - it doesn't parse multi-line block comments or understand any specific language's full comment syntax perfectly.
Example
# load settings
import json
def load(path):
# read the file
with open(path) as f:
return json.load(f)
gives 7 total lines: 1 blank, 6 non-blank, of which 2 are comment lines - so 4 lines of actual code.
What Line Counts Are Good For
- Estimating the size of a file before a code review or refactor.
- Checking comment density - a large function with no comments, or one that is half commented-out code.
- Quick numbers for a report, a quote or a portfolio.
What They Are Not Good For
Lines of code measure size, not quality or effort. Ten careful lines can be harder to write than two hundred generated ones, and the same logic can take very different line counts in different styles. Use counts to compare files within one project, not to judge people.
Counting a Whole Project
For a whole repository, command-line tools such as cloc, tokei or scc count every file by language and skip vendor folders.
Clean up before counting with the Code Comment Remover or the Code Beautifier.
Frequently Asked Questions
Explore More Tools
Keep going with related categories and our most used tools.