Skip to content
πŸ› οΈToolsShed

Sentence Length Analyzer

Analyze the length distribution of sentences in any text.

About this tool

A sentence length analyzer is a writing tool that examines the length distribution of sentences in any text. It helps writers understand readability patterns, identify structural variety, and recognize whether their writing flows naturally or becomes monotonous. Whether you're crafting an essay, refining a blog post, editing professional documentation, or teaching writing skills, this tool provides instant insights into the sentence structure of your work without requiring manual counting or complex analysis.

To use the sentence length analyzer, simply paste your text into the input field and the tool automatically calculates sentence lengths, displays a frequency distribution chart, and provides detailed statistics including average length, minimum, maximum, and median values. The visual breakdown helps you see at a glance whether your sentences are balanced or if you're relying too heavily on very short or very long sentences, making it easy to spot areas that need revision for better readability.

Frequently Asked Questions

Code Implementation

import re
from collections import Counter

def analyze_sentence_lengths(text: str) -> dict:
    sentences = [s.strip() for s in re.split(r'[.!?]+', text) if s.strip()]
    lengths = [len(re.findall(r'\b\w+\b', s)) for s in sentences]

    if not lengths:
        return {}

    categories = {"short": 0, "medium": 0, "long": 0, "very_long": 0}
    for length in lengths:
        if length <= 10:
            categories["short"] += 1
        elif length <= 20:
            categories["medium"] += 1
        elif length <= 30:
            categories["long"] += 1
        else:
            categories["very_long"] += 1

    return {
        "total_sentences": len(sentences),
        "avg_length": round(sum(lengths) / len(lengths), 1),
        "min_length": min(lengths),
        "max_length": max(lengths),
        "categories": categories,
        "sentence_lengths": list(zip(sentences, lengths)),
    }

text = """
The cat sat. The quick brown fox jumped over the lazy sleeping dog near the river.
This is a medium length sentence with some words.
"""
result = analyze_sentence_lengths(text)
for sentence, length in result["sentence_lengths"]:
    print(f"{length:3d} words: {sentence[:50]}...")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.