Skip to content
UniKit

Line counter

Count the lines, non-empty and empty lines of a text, plus the longest line, character count and UTF-8 byte size, with an option for how a trailing newline is treated.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

CRLF, LF and CR are all recognised; lines holding only spaces or tabs count as empty.

Statistics

Lines, empty lines, the longest line and character/byte counts are all computed locally — nothing is uploaded.

Enter text to see the line statistics

What this tool does

  • Paste a piece of copy to check the total and non-empty line counts and spot truncation
  • Measure a CSV, log or export file before importing it to see whether it is too large
  • Find which line is the longest and how long it is, to locate runaway lines

Example

Input

第一行
第二行

Output

Lines: 3
Non-empty: 2
Empty: 1
Longest line: #1 (3 characters)
Characters excluding line breaks: 6
UTF-8 bytes excluding line breaks: 18

The trailing newline counts as one blank line by default, so "第一行\n第二行\n" is 3 lines; switch that option off to get 2.

Frequently asked questions

Does a trailing newline count as a line?

Yes by default. After splitting on CRLF / LF / CR, "第一行\n第二行\n" yields three lines: two lines of content plus one blank line, matching an editor gutter. Turn off "Count the trailing newline as a blank line" to match the physical line count of a file instead, which gives 2.

What counts as an empty line?

Lines made up of nothing but spaces or tabs are empty too (the test is trim), so lines copied from Word or a web page that look empty but contain spaces are not miscounted as content. Empty lines appear in the "Empty" figure, and Non-empty = Lines − Empty.

How are the character and byte counts computed?

Characters are counted by Unicode code point and exclude line breaks, so an emoji counts as one character. The UTF-8 byte count also excludes line breaks and is derived from code point ranges (1 byte for ASCII, 3 for CJK, 4 for emoji), matching TextEncoder — handy for estimating storage or upload size.

How is the longest line determined?

Lines are compared by character count and the tool reports the line number (1 based) and length of the longest one; ties go to the earliest line. For empty input or all-blank text it shows "none".

Is the text uploaded?

No. Everything is computed in your browser; neither the input nor the report leaves your machine.

Keywords:line counterline-countoffline

Related tools