Line Counter

Count lines in any text and see non-empty lines, empty lines, average length, longest line, and shortest non-empty line in your browser.

0 lines; 0 non-empty; 0 empty

How to use the line counter

1. Paste or type your text

Drop a code file, log, CSV, screenplay, or any plain text block into the box. Counting starts the moment you type. Paste from VS Code, Sublime, Terminal output, Google Docs, or email; the counter reads them all the same way.

2. Read the headline number

The red total at the top of the sidebar is the total line count. It updates on every keystroke and matches the line numbers shown in most code editors (VS Code, Sublime, Notepad++).

3. Check the breakdown

Non-empty lines and empty lines split the total. Average characters per line shows how dense the text is; long blocks of code or prose have higher averages, sparse logs or screenplay dialogue have lower.

4. Inspect longest and shortest

The longest line panel shows the line itself with its character count, useful for catching runaway one-liners or lines that bust an 80- or 120-character limit. The shortest non-empty line skips blank rows so a few empty gaps do not collapse the metric to zero.

5. Tune with the toggles

Turn off Count empty lines if you only want lines with content in the total. Turn on Trim before counting to treat whitespace-only lines as empty and to ignore indentation when comparing line lengths.

When you need a line counter

Code review and pull-request sizing

Reviewers cap reasonable pull requests at around 400 lines of changed code; bigger diffs get rubber-stamped or split. Drop the diff into the counter to confirm a PR is in range before sending it for review. Pair it with the longest-line check to flag formatting issues that bloat the diff (long object literals, unwrapped strings).

Log inspection and post-mortem prep

When you grep a log for an error and need a quick line count, paste the filtered output into the counter. Total lines tells you how many matching events fired; non-empty filters out blank separator rows. It is faster than piping through wc -l on a remote server when you already have the output on your clipboard.

CSV row sanity check

Before importing a CSV into a database or spreadsheet, paste it into the counter to confirm the row count matches what the source claimed. Mismatches usually mean a multi-line cell escaped its quotes or a trailing newline added a phantom row. The counter catches the discrepancy in one read.

Screenplay and shot-list tracking

Screenplay format runs roughly one minute of screen time per page, and one page is roughly 55 lines. Counting lines in a draft scene gives a fast estimate of run time before formatting. Production teams use the same trick to size shot lists per scene.

Poetry rhythm and stanza length

Poets check line counts when tightening a stanza or matching syllables across lines. Drop a stanza into the counter and the longest-line and shortest-line panels show the visual rhythm at a glance. Pair with the syllable counter for full metrical analysis.

Programmer's note: blank lines vs executable lines

The counter reports physical lines, the same way an editor numbers them. That is not the same as lines of code (LOC) in the sense that engineering teams measure productivity or coverage.

Line typeCounted here?Counted by SLOC tools?
Executable code Yes (in total) Yes
Blank lines Yes (in total; subtotaled as empty) Usually no
Comment-only lines Yes (counted as non-empty) Tracked separately
Continuation lines Yes (each line counts once) Often folded into the parent statement
Multi-line strings Each newline counts Tool-specific

If you need executable-LOC (eLOC) or source-LOC (SLOC) for a code metric, use a dedicated tool like cloc, scc, or tokei. This counter is built for fast, editor-style line counts: a sanity check before a paste, a PR-size estimate, a log slice, or a file-size confirmation.

Lyrics: lines as song structure

Songwriters and producers use line counts to map structure. A standard verse runs 4 to 8 lines; a pre-chorus runs 2 to 4; a chorus runs 4 to 8. Counting lines per section gives a fast read on whether the arrangement is balanced or whether one part is dragging.

The shortest-non-empty-line panel is useful for catching one-word hook lines (the "yeah" or "oh" lines that producers sometimes pad into a chorus). The longest-line panel flags lines that will not fit a typical melodic phrase and might need a rewrite or a melisma.

For full lyric analysis, pair this counter with the sentence counter to track full sentences across the song and with the syllable counter for per-line metrical work.

Related tools

Frequently asked questions

What counts as a line?

A line is any run of characters between two newline markers (or between the start of the input and the first newline). Both Unix newlines (\n) and Windows newlines (\r\n) are recognized. An empty line is a line with zero characters or only whitespace, depending on whether the Trim toggle is on.

Does the counter include the final empty line if my text ends with a newline?

Yes. A trailing newline produces one extra empty line at the end, the same way most code editors and command-line tools (wc, awk) report it. If you do not want that line in the total, turn off Count empty lines and the counter will skip it.

What does the Trim before counting toggle do?

Trim strips leading and trailing whitespace from each line before measuring it. With Trim on, a line that holds only spaces or tabs is treated as empty, and the longest or shortest line length ignores indentation. Turn it off when you need exact byte length, including indentation.

Is this the same line count as wc -l?

Almost. The Unix wc -l counts the number of newline characters, so a file with no trailing newline reports one fewer line than the visible content suggests. This counter counts visible lines, so it reports the same value as most editors (VS Code, Sublime, Notepad++). If you need wc parity, the count will match when your file ends with a newline.

How does the counter handle CSV rows?

It counts every newline as a line break, including newlines inside quoted CSV fields. That means a CSV with multi-line cells (a description that wraps across rows) will report more lines than data rows. For pure data-row counts, sanitize the CSV first with a tool that respects quote-aware parsing.

I'm pasting log files and code snippets to count lines. Could any of that sensitive data be uploaded somewhere?

No. The line split runs locally in JavaScript using a newline regex. Log files, stack traces, and code snippets stay in the textarea and are never sent to any server.

Can I count lines of code with this tool?

Yes, but read the result with context. The counter reports physical lines, not logical lines of code. Blank lines, comment-only lines, and continuation lines all count as separate lines. For a code metric that separates blanks and comments, use a dedicated SLOC tool (cloc, scc, tokei). This counter is fastest for quick file-size sanity checks.

What is the shortest non-empty line?

It is the shortest line in the input that contains at least one visible character (after trimming, if Trim is on). The counter reports it separately from the shortest line overall so a file full of blank gaps does not collapse the metric to zero. The character count shown is the length of that line, not its position. See also: text scrambler.

More wordcounter.ai tools

Other tools you might find useful.

Browse the full catalog →