What does the Word & Character Counter do?
The Word & Character Counter provides instant, real-time text statistics and readability metrics directly in your browser. It calculates word counts, character counts (with and without whitespace), lines, sentences, paragraphs, average word length, silent reading duration (225 wpm), spoken presentation time (130 wpm), estimated AI LLM token usage (for GPT-4, Claude, and LLaMA), and top keyword density percentages.
Core Concepts
Key text metrics and readability formulas:
- Character Count Variations: Calculates total raw character length as well as whitespace-stripped character counts to evaluate SMS limits, meta tag SEO length (150–160 chars), or code string constraints.
- Reading vs. Speaking Speeds: Silent reading averages ~200–250 words per minute, whereas presentation speaking cadence averages ~130–150 words per minute.
- LLM Token Estimation: Modern Large Language Models (LLMs) break down English text into subword tokens (~4 characters or 0.75 words per token). Estimating tokens helps engineers gauge API payload sizes and stay within prompt window limits.
- Keyword Density: Identifies recurring non-stop words to help content writers optimize article readability without keyword stuffing.
How to use the tool?
- Type or Paste Text: Paste your draft, article, README, or LLM prompt into the text editor or click Load Sample.
- Review Real-Time Metrics: Counter cards instantly update as you type with zero lag.
- Copy Output: Click Copy to duplicate your text or check the keyword density breakdown.
Related Developer Utilities
If you work with text formatting, markdown documentation, and string manipulation, explore these complementary tools:
- Whitespace & Blank Line Cleaner: Clean irregular spaces, tabs, and excess empty lines.
- Text Diff & Compare Tool: Compare two text blocks line-by-line with inline diff highlighting.
- Add Line Numbers to Text: Prepend sequential line numbers to code blocks or logs.
- Text Case Converter: Convert strings between camelCase, snake_case, PascalCase, and kebab-case.
REST API Integration
Blueutils provides a free REST API endpoint (POST https://blueutils.com/api/text/word-counter) to programmatically calculate text statistics and token metrics.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
rawText |
String | Plain text string to analyze. | "Blueutils provides high-performance developer tools." |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/text/word-counter \
-H "Content-Type: application/json" \
-d '{
"rawText": "Blueutils is a high-performance developer utility suite designed for engineers."
}'Python
import requests
url = "https://blueutils.com/api/text/word-counter"
payload = {
"rawText": "Blueutils is a high-performance developer utility suite designed for engineers."
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String jsonPayload = """
{
"rawText": "Blueutils is a high-performance developer utility suite designed for engineers."
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/text/word-counter"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}API Response Parameters
| Name | Type | Description | Example |
|---|---|---|---|
isValid |
Boolean | Indicates whether analysis succeeded. | true |
words |
Number | Total word count. | 10 |
characters |
Number | Total characters including spaces. | 75 |
charactersNoSpaces |
Number | Characters excluding whitespace. | 66 |
sentences |
Number | Total sentence count. | 1 |
paragraphs |
Number | Total paragraph count. | 1 |
readingTime |
String | Estimated silent reading time. | "3 sec" |
speakingTime |
String | Estimated spoken duration. | "5 sec" |
estimatedTokens |
Number | Estimated LLM token count. | 19 |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"words": 10,
"characters": 75,
"charactersNoSpaces": 66,
"lines": 1,
"sentences": 1,
"paragraphs": 1,
"averageWordLength": 6.6,
"readingTime": "3 sec",
"speakingTime": "5 sec",
"estimatedTokens": 19,
"keywordDensity": [
{
"word": "blueutils",
"count": 1,
"density": 10,
"isStopWord": false
}
]
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "Input text must be a valid string."
}Rate Limit Exceeded Response (HTTP 429 Too Many Requests)
{
"error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}Why use an API for text statistics?
Integrating the Word Counter API into publishing pipelines, CMS workflows, or AI agent tool calling provides key benefits:
- Automated Reading Time Calculation: Automatically computes estimated article read times during static site generation (Hugo, Astro, Next.js).
- Prompt Size & Cost Auditing: Calculates character and token metrics before dispatching expensive LLM completions.
- Editorial Length Enforcement: Validates draft content limits during automated CI/CD checks for documentation repositories.
Native Usage
How to count words and characters natively in common developer environments:
Linux / Unix (wc command)
# Count words in a text file
wc -w document.txt
# Count characters (bytes)
wc -m document.txt
# Count lines
wc -l document.txtWindows (PowerShell)
# Count words in PowerShell
(Get-Content document.txt | Measure-Object -Word).Words
# Count total characters
(Get-Content document.txt -Raw).Length
# Count lines
(Get-Content document.txt | Measure-Object -Line).LinesWindows (Command Prompt)
:: Count lines in a file
find /c /v "" document.txtPython
text = "Blueutils provides developer tools."
words = len(text.split())
chars_with_spaces = len(text)
chars_no_spaces = len(text.replace(" ", ""))
print(f"Words: {words}, Characters: {chars_with_spaces}")Java
public class WordCounterExample {
public static void main(String[] args) {
String text = "Blueutils provides developer tools.";
String[] words = text.trim().split("\\s+");
System.out.println("Word count: " + words.length);
System.out.println("Characters: " + text.length());
}
}