Lexical Diversity Calculator — TTR, MTLD, HD-D

Paste an essay, transcript or language sample and get eight published lexical diversity indices at once — including the three that do not collapse as the text gets longer: MTLD, MATTR and HD-D. Every count runs in your browser; nothing is uploaded.

Analyse a text sample

Tokens per window. Standard is 50.
McCarthy & Jarvis default is 0.720.
Tokens (N)
Types (V)
Hapax (used once)
Most frequent type

The eight indices

IndexValueLength behaviourReading
Type-Token RatioTTR = V / Nlength-dependent
Root TTR (Guiraud)RTTR = V / sqrt(N)length-dependent
Corrected TTR (Carroll)CTTR = V / sqrt(2N)partly corrected
Herdan's CC = log(V) / log(N)partly corrected
Maas a²a² = (log N - log V) / (log N)²partly corrected
MSTTRmean TTR of consecutive W-token segmentslength-robust
MATTRmean TTR over all N-W+1 sliding windowslength-robust
MTLDN / factors, forward and backward averagedlength-robust
HD-D (vocd-D)sum of P(type in 42-token sample) / 42length-robust

MTLD passes: . Bands are rules of thumb for English prose at the default settings, not normative cut-offs — only the MTLD anchor near 72 comes from a published corpus mean (McCarthy & Jarvis 2010). Compare texts with each other, using identical settings.

MATTR across the text

Each point is the type-token ratio of one sliding window. Dips mark passages where the wording repeats itself.

How each index is computed

Tokens are the running word forms of the text; types are the distinct lowercased forms among them. Everything below is derived from those two counts, or from the token sequence itself.

The ratio family (length-dependent)

Plain TTR is types over tokens. It has one fatal property: it falls as the text grows, because function words recur while new content words arrive ever more slowly. Two texts are only comparable by TTR if they have the same token count. Root TTR (Guiraud, 1954) and Corrected TTR (Carroll, 1964) divide by the square root of N and of 2N to damp that decline; Herdan's C (1960) and Maas (1972) apply logarithmic transformations for the same reason. All of them reduce the length effect without removing it.

TTR = V / N RTTR = V / sqrt(N) CTTR = V / sqrt(2N) C = log(V) / log(N) a² = (log N - log V) / (log N)² lower a² = more diverse

The window family (MSTTR and MATTR)

MSTTR chops the text into consecutive non-overlapping segments of W tokens (default 50), computes TTR in each and averages them; any leftover tokens shorter than one full segment are discarded, so MSTTR ignores up to W-1 tokens at the end. MATTR (Covington & McFall, 2010) instead slides a window of W tokens one token at a time and averages the TTR of all N-W+1 windows, which uses every token and gives a smooth series you can plot — that is the sparkline above.

MTLD

MTLD (McCarthy & Jarvis, 2010) measures the mean number of tokens it takes for the running TTR to fall to the factor threshold of 0.720. The algorithm walks through the tokens keeping running type and token counts; when the running TTR reaches the threshold, one factor is recorded and both counters reset. Whatever is left over at the end contributes a partial factor. The whole procedure is run forward and then over the reversed token list, and the two results are averaged.

for each token: tokens += 1; if new form then types += 1 ttr = types / tokens if ttr <= 0.720: factors += 1; reset types, tokens, ttr = 1 partial = (1 - ttr_remaining) / (1 - 0.720) MTLD_pass = N / (factors + partial) MTLD = (MTLD_forward + MTLD_backward) / 2

Because MTLD counts how far the text travels before diversity decays, it is expressed in tokens: a value of 80 means the running TTR survives roughly 80 tokens before dropping to 0.720. If a text never reaches the threshold (very short or entirely unique wording) no full factor exists and MTLD cannot be computed — the tool says so rather than inventing a number.

HD-D

HD-D (McCarthy & Jarvis, 2007) replaces the random sampling of vocd-D with the exact hypergeometric probability. For every type t with frequency f, it computes the chance that at least one of its tokens lands in a random draw of 42 tokens from the text, weights that probability by 1/42, and sums over all types. The 42-token sample is the midpoint of the 35-to-50 range used by the original vocd-D curve fit, which is why HD-D reproduces vocd-D deterministically.

HD-D = sum over types t of [ 1 - C(N - f_t, 42) / C(N, 42) ] × (1/42)

The binomial coefficients would overflow double precision for texts of a few hundred words, so this page evaluates them in log space with a Lanczos log-gamma: log C(n,k) = lgamma(n+1) - lgamma(k+1) - lgamma(n-k+1), and the ratio is recovered with a single exponential. Any type frequent enough that N - f is below 42 is certain to appear, contributing exactly 1/42.

Sample-size limits

Frequently asked questions

Why is plain TTR a poor measure of lexical diversity?
TTR is types divided by tokens, and it falls automatically as a text gets longer because function words repeat while new content words arrive more slowly. A 100-word sample and a 1000-word sample from the same writer produce very different TTRs, so TTR can only compare texts of identical length. MTLD, MATTR and HD-D were designed to remove that dependence.
What counts as a token here?
A token is any run of letters, optionally containing an internal apostrophe, after the text is lowercased. Numbers and punctuation are ignored. A type is a distinct token form, so "Walk" and "walk" are one type, while "walk" and "walked" are two unless you enable inflection normalisation.
What is a good MTLD value?
McCarthy and Jarvis reported corpus means around 72 for adult English writing, and most connected prose lands roughly between 50 and 100. Below 50 suggests noticeably repetitive vocabulary; above 100 suggests unusually varied wording, which is common in academic or technical text. Genre matters more than any absolute cut-off, so compare like with like.
Why do MSTTR and MATTR differ slightly?
MSTTR averages non-overlapping segments and discards the tail that does not fill a whole segment, while MATTR averages every overlapping window and uses all tokens. MATTR is therefore smoother and less sensitive to where the segment boundaries happen to fall, which is why it is generally preferred.
Does the inflection option do real lemmatisation?
No. It applies Porter-style suffix stripping to plurals and to the -ed and -ing endings, which merges walk, walks, walked and walking but will not handle irregular forms such as went or children. Treat it as a rough content-form normaliser, not a dictionary lemmatiser.
Is my text uploaded anywhere?
No. Tokenisation and every index are computed in JavaScript inside your browser. There are no network requests, no analytics and no storage; closing the tab discards everything.