#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
📐 FREE · VECTORS & TEXT

Cosine Similarity Calculator: How Alike Are Two Vectors?

Compare two number lists or two texts and get similarity from −1 to 1.

  • 🔢 Any number of dimensions
  • 📝 Text mode with word counts
  • 📏 Angle and distance too

How to use the Cosine Similarity Calculator

  1. 1. Choose vectors or textPick whether you are comparing numbers or sentences.
  2. 2. Enter A and BType the two vectors (same length) or paste two texts.
  3. 3. Read the similaritySee the cosine value, angle, dot product and magnitudes.

The formula with an example

cos θ = (A · B) ÷ (‖A‖ × ‖B‖), where A · B is the dot product and ‖A‖ is the length (magnitude) of A. The result depends only on direction, not size, so a long document and a short one about the same topic can still score high.

For A = (1, 2, 3) and B = (4, 5, 6): A · B = 4 + 10 + 18 = 32, ‖A‖ = √14 = 3.7417 and ‖B‖ = √77 = 8.775. So cos θ = 32 ÷ 32.8329 = 0.9746, an angle of about 12.93°. The vectors point in almost the same direction.

Where it is used

  • Search and recommendations: compare a query vector with document or product vectors.
  • Embeddings and RAG: vector databases rank text chunks by cosine similarity of their embeddings.
  • Text matching: duplicate questions, plagiarism checks, resume-to-job matching.
  • Clustering with cosine distance (1 − similarity).

Text mode here builds simple word-count vectors, so it measures shared words, not meaning: "car" and "automobile" count as different. Real semantic search uses embeddings from a language model, which this page does not create. With all-positive vectors such as word counts, similarity ranges from 0 to 1. Weight rare words more with the TF-IDF calculator, or compare other distances in the distance calculator.

Frequently asked questions

Can cosine similarity be negative?

Yes, when vectors point in opposite directions. With counts or other all-positive values it stays between 0 and 1.

Is my text sent anywhere?

No. Words are counted in your browser.

Is the Cosine Similarity Calculator free?

Yes, the Cosine Similarity Calculator is free. The first time you see your first result, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.

More free tools

See all free tools