How to use the Cosine Similarity Calculator
- 1. Choose vectors or textPick whether you are comparing numbers or sentences.
- 2. Enter A and BType the two vectors (same length) or paste two texts.
- 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.