Count Paragraphs in Text

Count the number of paragraphs in any text. Learn how paragraph detection works, the difference between blank-line-separated and newline-separated paragraphs, and how paragraph structure affects readability.

Text Metrics

Detailed Explanation

Paragraph Counting

A paragraph is a block of related sentences grouped together. In plain text, paragraphs are typically separated by blank lines (two consecutive newline characters).

Basic Paragraph Detection

The standard approach splits on double newlines:

function countParagraphs(text) {
  const trimmed = text.trim();
  if (!trimmed) return 0;
  const paragraphs = trimmed.split(/\n\s*\n/);
  return paragraphs.filter(p => p.trim().length > 0).length;
}

The regex /\n\s*\n/ matches a newline, optional whitespace, and another newline — this catches blank lines that may contain spaces or tabs.

Single Newline vs. Double Newline

There are two conventions for paragraph separation:

  1. Blank-line separated (Markdown, LaTeX, most prose):

    First paragraph.
    
    Second paragraph.
    

    Here, a single newline within a paragraph is treated as a soft line break, not a paragraph boundary.

  2. Single-newline separated (some data formats, poetry):

    First paragraph.
    Second paragraph.
    

    Each newline starts a new paragraph.

Most word processors and web content use the blank-line convention. The counter should ideally support both modes.

HTML Paragraph Detection

In HTML content, paragraphs are marked by <p> tags:

function countHtmlParagraphs(html) {
  const matches = html.match(/<p[\s>]/gi);
  return matches ? matches.length : 0;
}

Paragraph Length Guidelines

Readability research suggests:

  • Web content: 2-4 sentences per paragraph (shorter for mobile)
  • Academic writing: 4-8 sentences per paragraph
  • Fiction: varies widely, from single sentences to full pages
  • Technical docs: 3-5 sentences per paragraph

Short paragraphs create visual whitespace that makes text more scannable on screens. Blog posts with paragraphs longer than 5 sentences tend to have higher bounce rates.

Paragraph Metrics

Beyond counting, useful paragraph metrics include:

  • Average paragraph length (words per paragraph)
  • Paragraph length variance (consistent vs. varied)
  • Longest/shortest paragraph (outlier detection)
  • Single-sentence paragraphs (used for emphasis, but overuse weakens writing)

Use Case

Writers and editors use paragraph counting to ensure consistent document structure. Web content creators check that paragraphs are short enough for mobile readability. Academic reviewers verify that essays have sufficient paragraphing, and SEO analysts check paragraph density as part of content audits (2-3 sentence paragraphs perform best for web content).

Try It — Word Counter

Open full tool