ls-metrics command analyzes a file and outputs various readability metrics and statistics as JSON.
Usage
Path to the file to analyze. The file must exist.
Output Format
The command outputs a JSON object containing computed metrics:Metrics Explained
Basic Statistics
Number of paragraphs in the document.
Total sentence count.
Total word count, excluding punctuation.
Total character count, including spaces.
Total syllable count across all words.
Count of words with three or more syllables.
Estimated reading time in minutes, based on average reading speed of 200 words per minute.
Readability Scores
Vale calculates several standard readability indices:Automated Readability Index (ARI)Estimates the U.S. grade level needed to comprehend the text. Based on characters per word and words per sentence.
- Lower scores (1-5): Elementary school
- Middle scores (6-10): Middle/high school
- Higher scores (11+): College level
Coleman-Liau IndexEstimates U.S. grade level using character count instead of syllables.
- Score of 8: Eighth grade reading level
- Score of 12: High school senior reading level
Flesch-Kincaid Grade LevelTranslates the Flesch Reading Ease score into a U.S. school grade level.
- Score of 6: Sixth grade level
- Score of 10: Tenth grade level
- Score of 13+: College level
Flesch Reading EaseRates text on a 100-point scale. Higher scores indicate easier readability.
- 90-100: Very easy (5th grade)
- 60-70: Standard (8th-9th grade)
- 30-50: Difficult (College level)
- 0-30: Very difficult (College graduate)
Gunning Fog IndexEstimates years of formal education needed to understand the text.
- Score of 8: Eighth grade level
- Score of 12: High school senior level
- Score of 17+: College graduate level
SMOG Index (Simple Measure of Gobbledygook)Estimates years of education needed to understand a piece of writing.
- Score of 10: Tenth grade level
- Score of 14: Undergraduate level
Linsear Write FormulaDesigned specifically for technical writing. Calculates grade level based on easy and hard words.
- Score below 8: Easy for students
- Score of 8-11: Medium difficulty
- Score above 11: Difficult
Examples
Use Cases
Verify Readability Goals
Check if content meets readability targets:Track Content Complexity
Monitor documentation complexity over time:Generate Reports
Create readability reports for multiple files:CI/CD Integration
Enforce readability standards in continuous integration:GitHub Actions
How Metrics Are Calculated
Text extraction
Vale processes the file using a minimal configuration that extracts plain text while respecting markup structure.
Metrics are calculated using a default
.txt format configuration. For Markdown or other markup, Vale processes only the text content, excluding code blocks and similar elements.Understanding Readability Scores
Target Scores by Audience
| Audience | Flesch Ease | Grade Level | Fog Index |
|---|---|---|---|
| General public | 60-70 | 7-8 | 8-10 |
| Technical docs | 50-60 | 9-10 | 10-12 |
| Academic | 30-50 | 13+ | 12+ |
| Marketing | 60-80 | 6-8 | 8 |
Improving Scores
To improve readability metrics:- Shorten sentences - Break complex sentences into shorter ones
- Use simpler words - Replace polysyllabic words with shorter alternatives
- Reduce passive voice - Use active constructions
- Add paragraphs - Break up long blocks of text
- Vary sentence length - Mix short and medium sentences
Limitations
- English only - Metrics are designed for English text and may not be accurate for other languages
- Single file - The command processes only one file at a time
- Estimation - Syllable counting and reading time are estimates
- No context - Metrics don’t account for document purpose or audience expertise