Line Counter
Count lines, blank lines, words and characters in text.
- Runs locally in your browser
- No upload required
Try it
Supported formats
Privacy
Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.
Counted 4 line(s), 3 word(s) and 14 character(s).
How it works
- Normalised CRLF and lone CR line endings to LF.
- Split the text into logical lines; one trailing newline is not an extra line.
- Counted non-empty and blank lines.
- Counted words as whitespace-separated runs and characters by Unicode code point.
- Measured the longest line by code point.
- Characters are counted by Unicode code point, not UTF-16 units.
- The same logical text counts identically whether it uses LF or CRLF.
Methodology
- Normalise every CRLF and lone CR to LF.
- Split into logical lines, treating one trailing newline as the line terminator rather than a new line.
- Count non-empty lines as those whose trimmed length is greater than zero.
- Count words over the trimmed text and characters by Unicode code point.
- Report the longest line by code point.
Usage
- Paste or type the text to analyse.
- Run the tool.
- Read the counts; the longest line shows the widest line by code point.
Examples
These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.
Mixed lines
{
"text": "one\ntwo\n\nthree"
}CRLF document
{
"text": "alpha\r\nbeta\r\ngamma"
}Empty input
{
"text": ""
}Limitations
Counting lines correctly
Most disagreements about a line count come from line endings and trailing newlines. This tool normalises CRLF and CR to LF and treats a single trailing newline as a terminator, so the count matches what an editor shows.
Frequently asked questions
- How are CRLF line endings handled?
- They are normalised to LF before counting, so a file saved with Windows line endings counts the same as one with Unix endings.
- Why does the character count differ from the byte count?
- Characters are counted by Unicode code point. A non-ASCII character such as é is one character but two UTF-8 bytes.
Sources
- ECMA-262: ECMAScript Language Specification — Ecma International
- MDN Web Docs — String.prototype.split() — Mozilla
Send feedback
Tell us if this tool helped, report a problem, or suggest a tool. Only the message you type is sent — never the input you used in the tool.
Was this tool useful?
Prefer to write to us directly? See the contact page.