Cosine Similarity Calculator

Measure how similar two vectors are in direction, regardless of size. Enter the components of Vector A and Vector B to get the cosine similarity, the angle between them, their dot product, and their magnitudes.

Quick Facts

Formula
cos(θ) = (A · B) / (|A| × |B|)
Measures the angle between two vectors, so it ignores their length entirely.
Range
−1 to 1
1 = same direction, 0 = orthogonal (unrelated), −1 = exactly opposite.
2D input?
Leave a Z component at 0
Setting both Z values to 0 reduces the calculation to a 2D vector comparison.

Your Results

Calculated
Cosine similarity
-
cos(θ), range −1 to 1
Angle between vectors
-
θ = arccos(cosine similarity)
Dot product (A · B)
-
Sum of matching component products
Vector magnitudes
-
Euclidean length |A| and |B|

Ready

Enter both vectors' components, then press Calculate.

Understanding Cosine Similarity

Cosine Similarity:

cos(θ) = (A · B) / (|A| × |B|)

Ranges from −1 (opposite direction) to 1 (same direction)

Cosine similarity measures how similar two vectors are in direction, independent of their magnitude (length). It is the cosine of the angle θ between vector A and vector B in whatever-dimensional space they occupy. The formula divides the dot product of the two vectors by the product of their magnitudes (Euclidean norms), which cancels out scale — a vector and a longer copy of itself pointing the same way still score a perfect 1.

The pieces of the formula

  • Dot product (A · B): multiply each pair of matching components and add the results — for 3D vectors, A·B = axbx + ayby + azbz.
  • Magnitude (|A|): the vector's Euclidean length, |A| = √(ax² + ay² + az²), and likewise for |B|.
  • Angle (θ): once cos(θ) is known, the angle itself is θ = arccos(cos(θ)), usually reported in degrees.

This calculator works with two 3-dimensional vectors. To compare 2D vectors, leave both Z components at 0 — the extra dimension contributes nothing to the dot product or the magnitudes, so the result is identical to a true 2D calculation.

Reading the result

A value of 1 means the vectors point in exactly the same direction (perfectly similar). A value of 0 means they are orthogonal — perpendicular, with no directional relationship. A value of −1 means they point in exactly opposite directions. Values in between indicate partial similarity: the closer to 1, the more the vectors align.

Common applications

  • Text and document similarity: comparing word-frequency or embedding vectors to find similar documents, articles, or search results.
  • Recommendation systems: comparing user or item feature vectors to suggest similar products, movies, or content.
  • Machine learning and NLP: measuring closeness between word or sentence embeddings produced by models.
  • Image and audio matching: comparing feature vectors extracted from images or audio clips for similarity search.

Cosine similarity is popular for these tasks because it ignores magnitude: a short document and a long document that use the same words in the same proportions will still score close to 1, which is usually the desired behavior when magnitude (like document length) is not itself meaningful.

Frequently Asked Questions

What does a cosine similarity of 0 mean?
A score of 0 means the two vectors are orthogonal (perpendicular) in the space they share — their dot product is zero, so there is no linear directional relationship between them. It does not necessarily mean the underlying items are completely unrelated, only that their vector representations point in unrelated directions.
Can cosine similarity be negative?
Yes. The formula ranges from −1 to 1 for any real-valued vectors. A negative value means the vectors point in generally opposite directions. In practice, when vectors only ever have non-negative entries (like raw word counts), the result is usually restricted to the 0-to-1 range, since a dot product of non-negative numbers can't be negative.
How is cosine similarity different from Euclidean distance?
Euclidean distance measures how far apart two points are in space, so it is sensitive to magnitude. Cosine similarity measures only the angle between vectors and ignores magnitude entirely. Two vectors can be far apart by Euclidean distance yet have a cosine similarity of 1 if they point in exactly the same direction — for example, (1, 1, 1) and (5, 5, 5).
Why do I need magnitudes if cosine similarity ignores them?
The magnitudes |A| and |B| are part of the formula's denominator — they are what makes the result scale-independent in the first place. Showing them separately just lets you see each vector's length alongside the direction-only similarity score, which is useful context even though the final ratio has canceled the scale out.