TF-IDF (term frequency times inverse document frequency) is a score that shows how important a word is to one document compared with a whole set of documents: high when the word is common on that page but rare elsewhere. It is one of the oldest ideas in information retrieval. In SEO it turns up in content tools that compare your page with pages that already rank.
What is TF-IDF? #
It joins 2 counts:
- Term frequency (TF): how often the word appears in this document.
- Inverse document frequency (IDF): how rare the word is across the whole collection. A word found in every document gets an IDF near 0. A word found in very few gets a high IDF.
Multiply them and you get TF-IDF. Everyday words such as “the” or “and” score near 0 everywhere, because they are in every document. A word like “limescale” scores high on a descaling guide and 0 on a page about shoes.
The idea of IDF is credited to the computer scientist Karen Spärck Jones, who described it as “term specificity” in a 1972 paper, as the Wikipedia article on tf-idf records.
How does it work? #
The textbook form uses N for the number of documents and df for how many of them contain the word:
idf = log(N / df)
tf-idf = tf x idf
Real software adds small changes. The scikit-learn library, widely used in Python, documents its tf-idf term weighting clearly. By default it uses:
idf(t) = log((1 + n) / (1 + df(t))) + 1
Its documentation says the extra 1s act as if one extra document held every word once, which prevents division by zero. It then scales each document’s scores to the same length (L2 normalisation), so long pages do not win just by being long. It also explains the point of the whole method: words like “the”, “a” and “is” are very common but carry little meaning, and raw counts would let them drown out rarer, more useful words.
Why does it matter for search? #
TF-IDF was a building block of early search engines. It helped rank documents in a search index by how well they matched the words in a query. Modern engines use far more than that. Google’s How Search works page says matching keywords is the most basic relevance signal, then describes language models, a synonym system and checks for other relevant content beyond the keyword itself. It says a page that repeats a word too much is not what people want.
So TF-IDF is best seen as a writing aid, not a ranking factor. SEO tools use it to compare your page with the top results for a query and list words those pages use that yours does not. That can reveal real gaps, such as a guide to kettles that never mentions “limescale”. It can also push writers to sprinkle in words for no reason. See content gap analysis and content optimisation.
Is it the same as keyword density? #
No. Keyword density is just one word’s share of a page’s words. It ignores the rest of the web. TF-IDF weighs each word by how rare it is across a collection, so it can tell a meaningful word from filler. Both share the same risk: chasing a number. Google’s spam policies list repeating words or phrases so often that it sounds unnatural as keyword stuffing. Its SEO Starter Guide adds that repetition “even in variations” is tiring for users.
Why does it matter for AI answers? #
Most AI search tools find passages with embeddings and vector search, which compare meaning. Some retrieval systems still blend in word-matching scores from the TF-IDF family, because exact terms such as model numbers, product codes and place names matter. The practical lesson for retrieval-augmented generation is the same either way: use the exact names of your products (each entity) and the exact words your customers use, once each where they fit. A page that says “our model” instead of the real model name is hard to match by words and by meaning. See semantic search.
Common mistakes #
- Treating the tool’s list as a quota. Adding a word 6 times because a rival used it 6 times.
- Copying the top 10. If every page says the same thing, matching them makes yours the 11th copy. Original detail beats it. See helpful content.
- Tiny or odd samples. IDF from 10 pages is noisy. Forums and shops in the same results skew the numbers.
- Ignoring intent. A word may be common on ranking pages because they serve a different search intent from yours.
- Forgetting the reader. The score cannot tell you if the page answers the question.
A worked example #
Take a collection of 1,000 pages and a 500-word guide to descaling a kettle. Using log base 10 for easy numbers:
| Word | Times on the guide (tf) | Pages containing it (df) | idf = log(1,000 / df) | tf-idf |
|---|---|---|---|---|
| the | 30 | 1,000 | 0 | 0 |
| kettle | 8 | 10 | 2 | 16 |
| limescale | 3 | 2 | 2.7 | 8.1 |
| water | 6 | 200 | 0.7 | 4.2 |
“The” appears 30 times but scores 0: it says nothing about the topic. “Limescale” appears only 3 times but scores highly because it is rare. Real tools use different formulas, as scikit-learn shows, so their numbers will differ, but the order of words is what matters.
How to check it #
- Read your page next to the top results for the query. Note subjects they cover and you do not, not just words.
- Check the topics your headings cover with the free Heading Answer Gap Finder and the Question Coverage Mapper.
- Count words with the Word Counter if you want to see repetition plainly.
- Compare two of your own pages for overlap with the Duplicate Content Comparer, or a rival’s page with Compare Two Websites.
- Make sure the finished page reads well with our Readability Checker, and that its title and description say what it is with the Meta Tag Checker.
- In URSY Pro, the Content brief builder plans a page from real questions, and the Plain English editor keeps it readable.
Questions #
Does Google use TF-IDF? #
Google does not publish its formulas. It says it uses keyword matching as a basic signal, plus language models and synonyms. Do not write for one formula.
Is a TF-IDF tool worth using? #
As a checklist of subjects you may have missed, yes. As a target to hit, no.
What is a good TF-IDF score? #
There is none. Scores only mean something compared with other words and pages in the same collection.
Related words #
Sources #
- scikit-learn: Feature extraction, tf-idf term weighting, checked 24 November 2026
- Wikipedia: tf-idf, checked 24 November 2026
- Google: How Search works, ranking results, checked 24 November 2026
- Google Search Central: Spam policies for Google web search, checked 24 November 2026
- Google Search Central: SEO Starter Guide, checked 24 November 2026
Updated 24 November 2026 by URSY.com.
Cite this page: TF-IDF. URSY. Updated 26 November 2026. https://ursy.com/wiki/tf-idf/ · Section links
Tools for this
- LiveAI Readiness Checkeris your site ready for ChatGPT, Gemini, Claude? Score + fixesRun the check →
- LiveAI Bot Checkerwhich AI bots your robots.txt lets inRun the check →
- LiveRobots.txt Checker + Generatortest any address against your rules, or write new onesRun the check →
- LiveSchema Markup CheckerRun the check →