ForHosting KIT · Education

Cosine Text Similarity Calculator

Score how closely two passages use the same words, from 0 when they share none to 1 when their word patterns match. «The quick brown fox jumps over the dog» and its reshuffled twin share 7 terms. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Text a
The quick brown fox jumps over the dog.
Text b
A quick brown dog jumps over the fox.
You get
Cosine similarity
0.894427191
Dot product
8
Magnitude a
3.1622776602
Magnitude b
2.8284271247

This cosine text similarity calculator turns each passage into a word-frequency vector and measures the angle between those vectors. The resulting score runs from 0, when the texts share no counted words, to 1, when their word-frequency patterns point in the same direction. Alongside the score, it reports token counts, vocabulary size, vector magnitudes, the dot product, and shared terms. It is a deterministic, inspectable way to compare lexical content without a language model or an external service.

Turn two passages into comparable vectors

Paste one passage into each text field. The calculator converts both inputs to lowercase, extracts Unicode sequences made from letters or numbers, and keeps internal apostrophes in words such as “don’t.” Punctuation and spacing do not become vector dimensions.

Every distinct token across both passages forms one dimension of a shared vocabulary, while the number of appearances of that token becomes the coordinate for each text. For example, a word used three times contributes a frequency of three rather than merely recording that the word exists. This makes repeated subject vocabulary matter to the comparison.

The output includes the token count for each passage, the combined vocabulary size, and an alphabetically sorted list of terms found in both. Those details let you inspect what contributed to the result instead of accepting an unexplained score. Letter case alone never changes the score, but spelling, inflection, and different word choices can.

No stemming, synonym expansion, stop-word removal, or semantic interpretation is applied.

Read the cosine similarity score correctly

Cosine similarity divides the vectors’ dot product by the product of their magnitudes. The dot product increases when the same words occur in both passages, especially when their frequencies are high. Normalizing by both magnitudes makes the result less dependent on raw passage length than a simple shared-word count.

A score of 1 means the two frequency vectors have the same direction: their relative word-use patterns match, even if one passage repeats every word more times. A score of 0 means there are no shared counted terms. Establish a threshold with representative examples from your own documents, then use it consistently.

The returned dot product and magnitudes are included so students, analysts, and developers can verify the calculation or reproduce it elsewhere. Cosine similarity measures word-frequency structure; it does not prove authorship, copying, factual agreement, or equivalent meaning.

Choose this metric for transparent lexical comparison

Use this calculator when you need a fast, explainable baseline for content overlap. It works well for classroom demonstrations of vector space models, comparing drafts that are expected to reuse terminology, checking whether short descriptions cover similar vocabulary, or building a deterministic feature for a larger analysis pipeline. It differs from edit distance, which focuses on character-level changes and order, and from shingle comparison, which looks for matching sequences of neighboring words.

It also differs from embedding-based semantic similarity: embeddings may recognize related ideas expressed with different vocabulary, whereas this tool only rewards actual token overlap and frequency patterns. That limitation is often useful because every contribution can be traced to a shared term. Review the shared-terms list when a score seems surprising; common function words can raise similarity even when subject matter differs.

If those words should not count, remove them from both inputs before comparing.

Teach vector space similarity

Show how token frequencies, a dot product, and vector magnitudes combine into a reproducible cosine score.

Compare document drafts

Measure whether two revisions retain similar vocabulary and inspect the exact terms they continue to share.

Build a lexical baseline

Create a transparent reference score before evaluating more complex semantic or sequence-based comparison methods.

What does the cosine similarity score mean?

It ranges from 0 for no shared counted terms to 1 for frequency vectors with identical direction. Intermediate values indicate partial lexical overlap.

Does capitalization or punctuation affect the result?

Capitalization does not, because tokens are lowercased. Punctuation separates tokens except for apostrophes inside words.

Does this detect synonyms or similar meaning?

No. It compares exact lowercased word tokens and their frequencies, so different words with related meanings do not match automatically.

Is word order considered?

No. A frequency vector records how often each token occurs, not where it appears. Use a sequence-based method when order matters.

What score counts as similar enough?

There is no universal threshold. Values between 0 and 1 show partial word overlap, so set your own cut-off with representative documents and apply it consistently. A high score never proves copying, authorship or the same meaning.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/edu/cosine-text-similarity

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/edu/cosine-text-similarity \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text_a":"The quick brown fox jumps over the dog.","text_b":"A quick brown dog jumps over the fox."}'
{
  "text_a": "The quick brown fox jumps over the dog.",
  "text_b": "A quick brown dog jumps over the fox."
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "edu.cosine_text_similarity",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_chars_per_text100000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the cosine similarity score correctly

Values between those endpoints indicate partial lexical overlap, but there is no universal threshold for “similar enough.”

Choose this metric for transparent lexical comparison

API requests cost $0.002, while the pure calculation uses no network, randomness, stored state, or model inference.

What does an API request cost?

Each API request costs $0.002. The calculation is deterministic and requires no external model or network service.

Read the full KIT documentation →