Count line

Count total, code, comment, and blank lines with a rough comment percentage.

freeworks offlinenothing uploaded
ToolLine Counter
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Input is split into lines, blanks are counted, supported comment-only markers are recognized, and remaining nonblank lines are treated as code. Inline markers follow the selected language’s line-based rules.

  • The report exposes several size measures rather than one LOC definition.
  • Line scanning is a quick estimate, not a language parser.

Worked example

Count lines in JavaScript
Analyze code, comment, and blank line ratios
Input
											// Setup
const app = express();

// Routes
app.get('/', handler);
app.listen(3000);
										
Output
												Line Count Analysis
-------------------
Total lines:   6
Code lines:    3 (50%)
Comment lines: 2 (33%)
Blank lines:   1 (17%)
											

When to use this

Code reviews, classroom metrics, and repository size audits count lines.

Edge cases

  • // inside a multiline string can look like a comment.
  • Code with an inline comment is not a comment-only line.
  • Marker choice changes counts for #, --, and // languages.