DEV Community

miccho27
miccho27

Posted on

How to Add Text Readability Analysis to Your App in 5 Minutes

Readability scoring sounds academic until you need it. Content teams want to know if their articles are too complex. SEO tools need readability as a ranking signal. Writing apps want real-time feedback.

Here is how to add readability analysis to any app in 5 minutes using a free API.

The Problem

Building readability scoring from scratch means implementing:

  • Flesch Reading Ease (syllable counting is harder than you think)
  • Flesch-Kincaid Grade Level
  • Gunning Fog Index
  • Coleman-Liau Index
  • SMOG Index
  • Automated Readability Index

Each formula has edge cases. Syllable counting alone requires a dictionary or heuristic engine. That is a weekend project minimum.

Or you can make one API call.

Step 1: Get an API Key

Sign up at RapidAPI - Readability Score API (free tier: 100 requests/month).

Step 2: Send Text, Get Scores

Python

import requests

API_URL = "https://readability-score-api.p.rapidapi.com/analyze"
HEADERS = {
    "X-RapidAPI-Key": "YOUR_API_KEY",
    "X-RapidAPI-Host": "readability-score-api.p.rapidapi.com",
    "Content-Type": "application/json"
}

def analyze_readability(text: str) -> dict:
    response = requests.post(API_URL, json={"text": text}, headers=HEADERS)
    return response.json()

# Example
result = analyze_readability(
    "The Federal Reserve announced a quarter-point rate increase, "
    "citing persistent inflationary pressures in the consumer price index. "
    "Economists had anticipated the move following recent employment data."
)

summary = result["summary"]
print(f"Grade Level: {summary['avg_grade_level']}")
print(f"Reading Ease: {summary['reading_ease']}")
print(f"Reading Time: {summary['estimated_reading_time_minutes']} min")
Enter fullscreen mode Exit fullscreen mode

JavaScript (React Example)

import { useState } from 'react';

function ReadabilityChecker() {
  const [text, setText] = useState('');
  const [score, setScore] = useState(null);

  const analyze = async () => {
    const res = await fetch('https://readability-score-api.p.rapidapi.com/analyze', {
      method: 'POST',
      headers: {
        'X-RapidAPI-Key': 'YOUR_API_KEY',
        'X-RapidAPI-Host': 'readability-score-api.p.rapidapi.com',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ text }),
    });
    setScore(await res.json());
  };

  return (
    <div>
      <textarea value={text} onChange={e => setText(e.target.value)} rows={10} />
      <button onClick={analyze}>Analyze</button>
      {score && (
        <div>
          <p>Grade Level: {score.summary.avg_grade_level}</p>
          <p>Reading Ease: {score.summary.reading_ease}</p>
          <p>Flesch Score: {score.scores.flesch_reading_ease.score}</p>
        </div>
      )}
    </div>
  );
}
Enter fullscreen mode Exit fullscreen mode

curl

curl -X POST "https://readability-score-api.p.rapidapi.com/analyze" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: readability-score-api.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{"text": "Your text here. Write at least two sentences for accurate scoring."}'
Enter fullscreen mode Exit fullscreen mode

Step 3: Interpret the Results

Flesch Score Grade Level Audience
90-100 5th grade Children content
60-70 8th-9th grade General public (ideal for blogs)
30-50 College Academic papers, legal docs
0-30 Graduate Scientific journals

Rule of thumb: If your blog post scores below 50 on Flesch Reading Ease, simplify it. Most successful content sits between 60-70.

Real-World Use Cases

1. CMS Content Gate

Block publishing if readability exceeds target grade level:

result = analyze_readability(article_text)
if result["summary"]["avg_grade_level"] > 10:
    raise ValueError("Article too complex for general audience. Target: grade 8-10.")
Enter fullscreen mode Exit fullscreen mode

2. Batch Audit Existing Content

Score every blog post and find the ones that need rewriting:

for post in get_all_posts():
    score = analyze_readability(post.content)
    if score["scores"]["flesch_reading_ease"]["score"] < 50:
        print(f"REWRITE: {post.title} (Flesch: {score['scores']['flesch_reading_ease']['score']})")
Enter fullscreen mode Exit fullscreen mode

3. Writing Assistant Feedback

Show real-time readability as users type (debounce the API calls):

const debouncedAnalyze = debounce(async (text) => {
  if (text.length < 100) return;
  const result = await analyzeReadability(text);
  updateScoreDisplay(result.summary);
}, 1000);
Enter fullscreen mode Exit fullscreen mode

Why Not Build It Yourself?

You could. The formulas are public. But:

  • Syllable counting requires handling exceptions (e.g., "queue" = 1 syllable, not 3)
  • Edge cases: empty text, single sentences, very short text
  • You need to maintain it as formulas get updated

The API handles all of this in under 20ms from Cloudflare edge network.

Pricing

  • Free: 100 requests/month (enough for development + light production)
  • Basic ($5/mo): 5,000 requests/month
  • Pro ($15/mo): 50,000 requests/month

Get started


Do you check readability before publishing? What grade level do you target? I aim for 7-8 for general blogs and 5-6 for documentation.

Top comments (0)