We Value Your Privacy

We use cookies to enhance your browsing experience and analyze site traffic. All calculations happen locally in your browser - we never see or store your data. Learn more in our Privacy Policy

/
/
CalculateYogi
  1. Home
  2. Technology
  3. Lines of Code Calculator
Technology

Lines of Code Calculator

Paste code to count blank, comment and source lines the way cloc does, see the composition, and estimate effort with Basic COCOMO 81.

Load an example file
How do you want to measure?

Nothing is uploaded; the counting runs in your browser. Up to 2,000 lines.

Language

Effort model

COCOMO mode

A small, experienced team on a familiar problem in a stable environment. Boehm notes that very few organic-mode projects have exceeded 50 KSLOC.

$

Counting conventions

How each kind of line is counted

Every rule verified against cloc 2.10 on files in six languages. Where a rule is contestable, this table says so.

Kind of lineCounts ascloc agrees
A line with code and a trailing commentCode, onceYes
A blank line inside a block comment or docstringBlankYes
A #! line at the top of a fileCodeYes
#include, #define and other C/C++ directivesCodeYes
A whole line that is nothing but a string literalComment in Python, code elsewhereYes

Project scale

Decade bands

The bands are powers of ten, chosen here for readability rather than taken from a standard. For a real reference point, SQLite publishes its own size: 155.8 KSLOC (155,800 SLOC), counted the same way this page counts.

BandSLOC
Tinyup to 1,000
Smallup to 10,000
Mediumup to 100,000
Largeup to 1,000,000
Very largeup to 10,000,000
Massiveabove 10,000,000

COCOMO modes

Basic COCOMO 81 coefficients

Effort = a x (KSLOC)^b, from Boehm, Software Engineering Economics (1981). These are the Basic coefficients; the Intermediate model uses a different set plus fifteen cost drivers.

ModeabWhen it applies
Organic2.41.05Small, experienced team; familiar problem
Semi-detached3.01.12Mixed experience; some novelty
Embedded3.61.20Tight constraints; moving requirements

Line counts describe size, not value or quality. COCOMO 81 was calibrated on 63 projects in 1981; treat its effort, schedule and cost figures as an order-of-magnitude starting point for discussion, never as a plan or a quote.

Did this calculator solve your problem today?

Contributor

Reviewed by

Last updated: August 24, 2026
SupportI build these free tools with love, late nights, and way too much coffee. If this calculator helped you, a small donation would mean the world to me and help keep this site running. Thank you for your kindness!

Related Calculators

You might also find these calculators useful

Cyclomatic Complexity Calculator

Paste your code and get its cyclomatic complexity, function by function

Code Coverage Calculator

Coverage by criterion, checked against requirements we can cite

Big-O Complexity Calculator

Paste code, get its time and space Big-O with the derivation

DORA Metrics Calculator

Measure DevOps performance with four key metrics

Count the lines of code in your project

Paste a file and this page counts it the way cloc, scc and sloccount do: blank lines, comment lines and source lines of code, with every convention stated so you can check the numbers rather than trust them. If you already have counts from a tool, switch modes and type them in. Either way you also get a Basic COCOMO 81 effort estimate, with the development mode as your choice rather than an assumption.

What is SLOC?

SLOC — source lines of code — is a count of the lines in a file that carry code, excluding blank lines and comments. It is a size measure, not a quality measure. Two counts of the same file disagree mainly because the counting rules differ, which is why SEI's counting framework treats a stated checklist as part of the measurement, and why this page lists its rules. Physical SLOC counts lines; logical SLOC counts statements, so a single physical line holding three statements counts once physically and three times logically. There is no fixed ratio between the two.

SLOC from a file's physical lines

How to count your lines of code

1

2

3

4

5

6

When this is useful

Sizing a codebase you inherited

Count what is actually there before estimating a migration or a rewrite, and separate hand-written code from generated files and vendored dependencies.

Sanity-checking an estimate

Run your SLOC figure through COCOMO in all three modes. If the spread is wider than the estimate you were given, the estimate depends on assumptions nobody has written down.

Reviewing documentation coverage

Compare comment ratios across modules to find the files that carry non-obvious logic with no explanation attached.

Reporting size honestly

Publish a line count with the counting rules beside it, the way SQLite publishes its 155.8 KSLOC, so the figure can be reproduced.

Why count lines of code

It is the input effort models need

COCOMO, function-point conversions and most parametric estimators take size in KSLOC. Without a size figure counted by a stated rule, the estimate has no anchor.

Comment ratio is a review signal

The share of documented lines that are comments tells you where a codebase sits between self-explanatory and unexplained — and flags files where the comments are commented-out code.

It makes scale concrete

"Large" is not a size. Knowing a codebase is 40,000 SLOC rather than 400,000 changes onboarding, review load and how many people can hold it in their heads.

It is comparable when the method is stated

A line count only means something alongside the rules that produced it. Matching a reference tool's conventions is what makes your number comparable with anyone else's.

Frequently asked questions

For a single file, paste it above. For a whole repository, run a directory-aware counter such as cloc, scc or tokei — this page counts one pasted file at a time, up to 2,000 lines, and matches cloc's per-line conventions so the two agree. If you already have a tool's output, switch to "I have the counts" and enter its blank, comment and code columns.

A line that carries at least one code character after comments are removed. Blank lines and lines that are purely commentary do not count. A line holding both code and a trailing comment counts once, as code, so the three classes always add up to the physical line count.

No. It counts once, as code. This page also reports how many such lines there were, so you can see how much of the file mixes the two — that number is a subset of the code count, not an extra class.

Physical SLOC counts lines; logical SLOC counts statements. A line holding three statements separated by semicolons is one physical line and three logical ones, and a statement wrapped over four lines is the reverse. This page counts physical SLOC. There is no fixed conversion between the two — it depends entirely on language and formatting style, so any single multiplier would be invented.

The usual reason is a different language being assumed, since comment markers differ. Check the detected-language badge and set it manually if needed. Beyond that, tools genuinely differ on edge cases: whether a shebang is code, whether a docstring is a comment, and how string literals occupying a whole line are treated. This page's rules are listed in the conventions table, each marked with whether cloc agrees.

Divide by 1,000. 12,500 SLOC is 12.5 KSLOC. COCOMO's original papers call the same quantity KDSI, thousands of delivered source instructions. The three names refer to the same measure; what varies between studies is the counting rule behind them, not the arithmetic.

No. Line count measures size, so it tells you how much there is to read, review and maintain — a cost, not an achievement. The same feature delivered in fewer lines is usually the better outcome. This is exactly why line count is a poor productivity metric and a reasonable size metric.

Basic COCOMO 81 was calibrated on 63 projects in 1981, before the tooling, languages and delivery practices most teams now use. Treat it as an order-of-magnitude check rather than a plan: useful for asking why an estimate is five times the model, not for committing to a date. Its own author replaced it with COCOMO II, which needs many more inputs than a line count.

CalculateYogi

The most comprehensive calculator web app. Free, fast, and accurate calculators for everyone.

Calculator Categories

  • Math
  • Finance
  • Health
  • Conversion
  • Date & Time
  • Statistics
  • Science
  • Engineering
  • Business
  • Everyday
  • Construction
  • Education
  • Technology
  • Food & Cooking
  • Sports
  • Climate & Environment
  • Agriculture & Ecology
  • Social Media
  • Other

Company

  • About
  • Contact
  • Contributors

Legal

  • Privacy Policy
  • Terms of Service
  • Editorial Policy

© 2026 CalculateYogi. All rights reserved.

Sitemap

Made with by the AppsYogi team