User Rating 0.0
Total Usage 0 times

Drag & Drop file here or Click to Upload

.txt, .js, .py, .html, .css (Max 10MB)

Total Lines 0
Non-Empty Lines 0
Empty Lines 0
Input / Preview
1
Is this tool helpful?

Your feedback helps us improve.

About

Counting lines of code (LOC) or text segments is a fundamental requirement in software development, content auditing, and data processing. Precision matters when billing clients based on source code volume or strictly formatting data for legacy systems. A standard text editor often obscures the difference between a truly empty line and one containing invisible whitespace characters like tabs or spaces.

This tool processes raw text and uploaded files to distinguish between total lines, non-empty lines, and purely whitespace lines. It handles cross-platform inconsistencies regarding line breaks, specifically the difference between Windows CRLF and Unix/Linux LF standards. Visual verification ensures that hidden characters do not inflate the final count.

line count loc counter text statistics code metrics file analysis

Formulas

The calculation defines the set of lines L derived from the input text T. The counting logic adjusts based on the presence of whitespace characters when Trim Mode is active.

{
counttotal = length(split(T, CRLF LF))countvalid = ni=1 (trim(li) ? 1 : 0)

Where trim removes leading and trailing whitespace W (spaces, tabs) from line li. The difference defines the empty line count.

Reference Data

StandardSymbolHex CodeOperating SystemsImpact on Count
Line FeedLF (\n)0x0ALinux, macOS, UnixStandard break. Counts as 1 new line.
Carriage ReturnCR (\r)0x0DLegacy Mac (Pre-OSX), CommodoreOften ignored or treated as overwrite in modern editors.
End of LineCRLF (\r\n)0x0D0AWindows, MS-DOSTwo bytes, but logically represents one line break.
Next LineNEL0x85EBCDIC MainframesRare. Requires specific encoding parsers.
Line SeparatorLS0x2028Unicode SystemsUsed in specific high-level formatting protocols.
Paragraph SeparatorPS0x2029Unicode SystemsDefines block boundaries rather than visual lines.
Null CharacterNUL0x00Binary FilesTerminates strings in C-based languages.
Vertical TabVT0x0BLegacy PrintersMoves cursor down without carriage return.

Frequently Asked Questions

Yes. If text appears on the final line without a trailing newline character (EOF), it is still counted as a valid line. Many terminal tools incorrectly report N-1 lines in this scenario; this tool counts visually apparent lines.
Standard mode counts these as non-empty lines because they contain data (whitespace characters). If you enable "Trim Mode", the parser ignores lines consisting solely of whitespace, categorizing them as empty lines.
Browser-based parsing loads the entire file into the DOM memory. A 10MB limit ensures the browser tab does not crash or freeze during the split and render process, especially when generating the visual line preview.
Minified code (like .min.js) often resides on a single line. The counter will report 1 line regardless of the file size (e.g., 500KB). You must format or "pretty print" the code before pasting if you require a logical line count.
No. The logic relies on text-decoding algorithms (UTF-8). Uploading images or executables will result in garbage data or incorrect line counts due to the random occurrence of byte sequences resembling line breaks.