Source Code Counter (SCC)

SCC is a cross-platform tool written in Java to count the number of lines in source code files. Counting the number of lines in source code files can usually be done using command line tools under Unix or with an IDE, but SCC extends this to be a far easier and more customisable process. This is achieved using the following methods:

Apart from an abstract interest in the number of lines of code in a particular project, there are two main use cases for SCC.

The first use case is when developing software commercially it is important to be able to demonstrate some level of productivity. As a measure of productivity or function count, lines of code is actually a poor indicator but is often used when no other indicators are readily available. SCC makes it fairly easy to count lines of code and remove blank lines and boilerplate statements such as copyright and coding comments that can distort the actual programmer created lines of code written.

The second use case is checking the quality of code to ensure that certain things are present (e.g. copyright statement) or alternatively missing (e.g. missing alt attribute from HTML img tags). In the Java world tools like Checkstyle and PMD can be run to verify certain things based on rules. These tools should still be used, but SCC augments this checking process in a few ways.

Other Features


SCC is open source software distributed under the terms of the GPLv3.

Download v1.0

Note: You will need the Java 6 JRE installed for your operating system to run Source Code Counter.


You can subscribe to updates at

Screen Shots

Tab 1 - Selected files to count

Files can either be dragged from your operating system's file manager or you can use the Add Files button. A file selection can be saved for later re-use. Note that unknown file types are highlighted in red. Makefiles have been selected in the File Types list on the left, which has selected all Makefiles in the File Selection Table on the right.

Tab 1 - selecting files

Tab 2 - Selecting counters to apply

Which counters (regular expressions) to apply can be configured here.

Tab 2 - applying counters

Tab 3 - Count the files and see the results

The Count button is clicked to process the selected files and the results displayed in the tables.

Tab 3 - review the results


How do I print?
Export the results or file selection to a csv or text file respectively and open in a spreadsheet or text editor.
Why are some comments not counted?
The default regular expressions are looking for lines that start with either blank space or a comment. If you want to count comments regardless of where they appear remove the ^[ \t]* from the beginning of the regular expression.
What are unknown files?
Unkown files are files that don't have a definition on tab 2 within the file types tree, i.e. their file extension or file name is undefined. An example would be a Microsoft Word file such as cv.doc.
Why aren't unknown files treated as text by default?

Because unknown files are more likely to be binary than text and there's no point in trying to process a binary file. If you know that a file type is definitely textual you can add it to the file types list on tab 2.

You can however override this default behaviour by setting how unknown files should be treated from the Options menu.

Why isn't programming language X covered?

I've tried to cover as many languages as possible but have probably missed a few lesser known languages. You can add your own within the File Types tree on tab 2.

Alternatively, if there are languages you aren't going to use, just delete them (you can always get them back by resetting the list).

The default (non-exhaustive) list currently includes: Ada, Algol, ASP, Assembly, Awk, Bean Shell, C/C++/C#, Makefile, COBOL, CSS, CSV, Delphi/Pascal, Drools, Erlang, F#, Flex, Forth, Fortran, Groovy, Haskell, HTML, Java, JSP, JavaScript, LaTeX/TeX, Linux Kernel Config, Lisp, Lua, Modula3, Objective-C, Perl, PHP, Prolog, Python, Ruby, Scala, SED, Shell script, SQL, TCL/TK, Text, (Visual) Basic, Windows Batch script, XML (DTD, RelaxNG, Schema, Schematron, XSLT), XQuery, Yacc/Bison

Why do some files cause an error?
There are a number of reasons why a file may not be able to be read by the program.
  • Check that the file permissions allow you to read the file
  • Check that the file you're trying to read contains text
  • Check that you are reading the file with the right character set. If you see an error like Input length = 1 or an error on the console like java.nio.charset.MalformedInputException try changing the character set encoding in use from the Options menu.
When I add a directory why does it carry on adding files?
Check that there are no symbolic links creating a circular directory tree as SourceCodeCounter can't detect symbolic links.
How can I stop SCC from adding or counting files?
Click the rotating circle in the bottom right corner of the window.
How fast is Source Code Counter?

This rather depends on the machine you run it on, the number of files you want to process and the number of regular expressions. On an AMD Athlon 64 3000+ machine running Linux SCC can add the Linux source tree (~24,000 files) to the file selection table in a matter of seconds and be able to count all the files in a couple of minutes (193 files/second).

If you have a machine with a number of processing cores you can increase the number of file counters from the Options menu to count files in parallel and thus increase the speed.

How do I learn regular expressions?
Information on regular expressions (regex for short) can be found at Wikipedia and at Java specific regex information can be found in the API documentation.


Copyright © Nick Sydenham <>