What Is TF-IDF?

Flavio AmielWritten byFlavio Amiel Founder, Roborank
Updated July 15, 2026

TF-IDF (term frequency–inverse document frequency) is a numerical statistic from information retrieval that weighs how important a word is to one document within a larger collection. It multiplies how often a term appears in a document by how rare that term is across the whole corpus, so distinctive words score high and common words score low.

Key Takeaways

How TF-IDF Works

TF-IDF answers a narrow question: within a collection of documents, which words best characterize any single one of them? It does this by balancing two opposing forces. Term frequency rewards a word for appearing often in a document — a page that says “espresso” ten times is probably about espresso. Inverse document frequency then penalizes words that appear in lots of documents — “the” and “coffee” show up everywhere, so their weight is discounted, while a rarer, more discriminating term like “portafilter” keeps its punch. Multiply the two and you get a score that is high for words that are both prominent here and unusual elsewhere.

That balance is what made TF-IDF durable. It is a cornerstone of classic information retrieval and still powers plenty of search and text-mining systems. But it is a general statistic, not a window into Google’s ranking. Google’s own John Mueller has described TF-IDF as a fairly old metric that predates how much search has changed, and pointed out that its most defensible modern use is mundane — helping identify stop words to discard, not scoring pages to rank.

The TF-IDF Formula

In its common form:

TF-IDF(term, document) = TF(term, document) × IDF(term)

where IDF(term) = log( total documents ÷ documents containing the term ).

The logarithm is what keeps the rarity bonus from exploding: a term in 1 of 10,000 documents scores higher than one in 1,000, but not a thousand times higher. The catch for SEO is buried in that “total documents” figure — the corpus is Google’s entire index, which no outside tool can see. Every commercial “TF-IDF score” is therefore an estimate against a handful of ranking pages, not the real value.

Example of TF-IDF

The concept traces to a genuinely foundational document: Karen Spärck Jones’s 1972 paper, “A statistical interpretation of term specificity and its application in retrieval,” in the Journal of Documentation. Spärck Jones argued that a term’s value for retrieval should depend on its specificity — how narrowly it is distributed across a collection — which is exactly the inverse-document-frequency idea that still carries her name.

A short illustrative calculation shows the mechanism (numbers chosen for clarity, not from a real index). Suppose a 200-word article uses “portafilter” 4 times, so its term frequency is 4/200 = 0.02. Suppose the word appears in 100 of a 1,000,000-document corpus, giving IDF = log(1,000,000 ÷ 100) = log(10,000) = 4. The TF-IDF weight is 0.02 × 4 = 0.08. Swap in a common word like “coffee” that appears in 500,000 of the million documents, and IDF = log(2) ≈ 0.3 — a far smaller weight even at the same frequency. The distinctive term wins, which is the whole point. What the example also makes concrete is the limitation Mueller flags: change the corpus and every score shifts, so a number tuned against ten competitor pages tells you nothing reliable about how Google, working from billions of documents, actually weighs your text.

The thing people get wrong

I treat TF-IDF tools the way I treat a thesaurus: occasionally useful for ideas, never a checklist. The failure mode I see is a writer running a page through a TF-IDF optimizer, getting a list of “under-used terms,” and then bolting those words into sentences that did not need them — which is keyword stuffing dressed up in a spreadsheet. The genuine signal a TF-IDF tool surfaces is topic coverage: if every strong competitor mentions “warranty” and “return policy” and your page never does, that is worth knowing. But the number itself is not a target, and hitting some suggested weight buys you nothing with Google. Use it to find gaps in what you cover, then close them with real information, not by sprinkling terms to move a score.

Frequently Asked Questions

Does Google use TF-IDF?
Not directly as a ranking factor. Google uses many information-retrieval techniques and TF-IDF is an ancestor of them, but John Mueller has said it is an old metric and that Google’s systems have evolved far beyond it. Optimizing content to a TF-IDF target is not advised.
Who invented TF-IDF?
The inverse-document-frequency component was introduced by British computer scientist Karen Spärck Jones in a 1972 paper on term specificity. Term frequency is older still. Combined, they became one of the foundational weighting schemes in information retrieval.
What is TF-IDF used for?
It is used across information retrieval, text mining, and search to weight terms, rank documents by relevance to a query, and identify stop words. It is a general text statistic, not a Google-specific ranking mechanism.
Should I optimize my content for TF-IDF?
Use it for ideas, not as a target. A TF-IDF tool can reveal topics your competitors cover that you have missed, which is genuinely useful. But adding words to hit a suggested weight risks unnatural writing with no ranking payoff.

The Bottom Line

TF-IDF is a classic recipe for deciding which words make a document distinctive: reward terms that appear often here but rarely everywhere else. It underpins decades of search technology, yet Google does not rank pages on it directly, and you cannot even calculate a true version without Google’s full index. Mine it for coverage gaps, then ignore the number.

Sources

  1. A statistical interpretation of term specificity and its application in retrieval (Karen Spärck Jones, 1972)Journal of Documentation
  2. TF-IDF: Is It A Google Ranking Factor?Search Engine Journal

Rank & Cash — the weekly SEO breakdown

One practical teardown a week on ranking in search and getting cited by AI. No fluff.