📝 Line Counter

📝 Text Input

Start typing to see real-time line analysis

⚡ Line Options

📊 Line Statistics

Total Lines
{{ stats.totalLines }}
Non-Empty Lines
{{ stats.nonEmptyLines }}
Blank Lines
{{ stats.blankLines }}
Avg. Line Length
{{ stats.avgLineLength }}

📏 Line Length Analysis

Longest Line:
{{ stats.maxLineLength }} chars
Line {{ stats.longestLineNumber }}
Shortest Line:
{{ stats.minLineLength }} chars
Line {{ stats.shortestLineNumber }}

🔢 Text with Line Numbers

{{ numberedText }}

📈 Line Length Distribution

{{ range.range }} chars:
{{ range.count }} lines
⚠️ {{ error }}

ℹ️ About Line Counter

Line Counter analyzes plain text by splitting it into newline-delimited lines. It reports total lines, non-empty lines, blank lines, shortest and longest line length, average line length, and an optional numbered copy of the original text.

Use it for:

  • Checking source snippets, configuration files, and pasted logs before review or sharing.
  • Finding blank lines in generated output, CSV/TSV exports, or copied terminal text.
  • Adding stable line numbers to examples for bug reports, documentation, or support tickets.
  • Estimating line-length distribution before wrapping, trimming, sorting, or diffing text.

How counting works: Text entered in an HTML textarea is exposed to scripts with line breaks normalized to LF characters. This tool uses JavaScript string splitting, as defined for String.prototype.split(), so a trailing newline creates a final blank line in the displayed line count.

  • Total lines: every segment separated by LF, including empty segments.
  • Non-empty lines: lines containing at least one non-whitespace character.
  • Blank lines: empty lines and lines made only of spaces, tabs, or other whitespace.
  • Line length: JavaScript string length per line, not byte count or terminal display width.
  • Line numbers: optional three-character numeric prefixes, with an option to skip blank lines.

Example: alpha\n\nbeta gamma\n is counted as 4 total lines: two non-empty lines and two blank lines, because the final \n leaves an empty line after it.

Limitations: This is an editor-style line analyzer, not a replacement for command-line wc behavior. It does not count bytes, words, wrapped visual rows, grapheme clusters, or display columns, and very large pasted files may be limited by browser memory.

API Usage Example:

POST /api/tools/text/line-counter
Content-Type: application/json

{
    "text": "First line\nSecond line",
    "showLineNumbers": true,
    "skipBlankLines": false
}
Ready