Cosine Similarity Calculator cos θ
Measure how similar two vectors are by the angle between them — the metric behind embeddings and semantic search.
Enter two equal-length vectors. Separate components with commas or spaces.
Show working (LaTeX)
This free cosine similarity calculator measures how similar two vectors are by the angle between them — returning the cosine similarity, the angle, the dot product and the magnitudes, step by step.
How to use the cosine similarity calculator
Enter two equal-length vectors into the cosine similarity calculator above and press Calculate. It returns the cosine similarity (a number from −1 to 1), the angle between the vectors, and the dot product and magnitudes it used. As a vector similarity calculator it works in any number of dimensions — ideal for comparing word embeddings or feature vectors.

What is cosine similarity?
Cosine similarity measures the cosine of the angle between two vectors, ignoring their length and focusing purely on direction. See the cosine similarity reference for the formal definition.
Cosine similarity formula
$$\cos\theta=\frac{A\cdot B}{\lVert A\rVert\,\lVert B\rVert}=\frac{\sum_i A_i B_i}{\sqrt{\sum_i A_i^2}\,\sqrt{\sum_i B_i^2}}$$How to calculate cosine similarity step by step
- Take the dot product of the two vectors.
- Find each vector’s magnitude (length).
- Divide the dot product by the product of the magnitudes.
Worked example
For A = (1, 2, 3) and B = (4, 5, 6): the dot product is 32, $\lVert A\rVert=\sqrt{14}\approx 3.742$, $\lVert B\rVert=\sqrt{77}\approx 8.775$, so cosine similarity = $32/(3.742\times 8.775)\approx 0.975$ — an angle of about 12.9°, meaning the vectors point in nearly the same direction.
Cosine similarity to angle
| Cosine similarity | Angle | Meaning |
|---|---|---|
| 1.0 | 0° | Identical direction |
| 0.87 | 30° | Very similar |
| 0.5 | 60° | Somewhat similar |
| 0 | 90° | Orthogonal (unrelated) |
| −1 | 180° | Opposite |
Why cosine similarity matters in machine learning
Cosine similarity is the backbone of modern machine learning search. Embeddings turn text, images and users into vectors, and cosine similarity measures how close two of them point — powering semantic search, recommendation systems and retrieval-augmented generation (RAG). It builds directly on the dot product and unit vectors.
🤖 ML insight
Why cosine and not plain distance? Embeddings can have very different magnitudes, but it’s their direction that carries meaning. Cosine similarity ignores length, so “king” and “kings” score as nearly identical even if one vector is longer.
Cosine similarity vs Euclidean distance
Euclidean distance measures the straight-line gap between two points and is sensitive to magnitude; cosine similarity measures only the angle, so it is scale-invariant. For high-dimensional embeddings — where vectors can have wildly different lengths — cosine similarity is usually the better choice, which is why vector databases default to it.
The two are related: if you first normalise both vectors to unit length, ranking by cosine similarity and ranking by Euclidean distance give the same order. That’s why many pipelines normalise embeddings up front and then use whichever metric is faster.
Frequently asked questions
What range does cosine similarity have?
What does a cosine similarity of 0 mean?
What is cosine distance?
Do the vectors need the same number of dimensions?
Is the cosine similarity calculator free?
Cosine similarity calculator: summary
From comparing embeddings to powering semantic search, this cosine similarity calculator gives the similarity, angle and the working in one click. Pair it with the dot product calculator and the unit vector calculator.