Cosine Similarity Calculator
An interactive cosine-similarity and vector-distance calculator. Paste two vectors and instantly see their dot product, magnitudes, cosine similarity, cosine distance, the angle between them, and Euclidean and Manhattan distance — the exact numbers behind how embedding search decides which items are “close.” See why cosine ignores magnitude and when to prefer it over Euclidean distance.
Strongly similar
| Cosine distance 1 − similarity | 0.0347 |
|---|---|
| Dot product A · B | 0.97 |
| Magnitude |A| | 1.01 |
| Magnitude |B| | 0.995 |
| Euclidean distance L2 | 0.2646 |
| Manhattan distance L1 | 0.5 |
Cosine similarity is the default way to compare embeddings, because it measures whether two vectors point the same direction rather than how long they are. Given two vectors A and B, it is the dot product A · B divided by the product of their magnitudes |A| × |B|, which is exactly the cosine of the angle between them. The value runs from 1 (identical direction, angle 0°), through 0 (perpendicular, unrelated, 90°), to -1 (opposite, 180°). This calculator parses the two vectors you enter, prints that similarity and the angle it corresponds to, and shows the dot product and magnitudes it was built from so the number is never a black box.
Direction-only comparison is the whole point for text search. An embedding of a long document has a larger magnitude than an embedding of a short one, but length is not relevance — you want the passage that is about the same thing, which is the one pointing the same way. Euclidean distance, by contrast, measures the straight-line gap and so mixes direction with magnitude. The two agree when the vectors are normalized to unit length, which many embedding models do by default, so for normalized embeddings cosine similarity and Euclidean distance rank neighbours identically. Vector databases usually expose cosine distance — 1 − similarity — because search wants a value where smaller means closer.
Read the numbers here as a small worked example of what a vector index does at scale to millions of embeddings. Watch how scaling one vector (say doubling every component) leaves cosine similarity unchanged but grows the Euclidean and Manhattan distances, which is the difference the two metrics capture. Two cautions: in very high dimensions distances concentrate — everything drifts toward middling similarity, so absolute thresholds are unreliable and ranking matters more than the raw score; and real embeddings live in hundreds or thousands of dimensions, so a hand-entered two or three-dimensional example builds intuition but does not reproduce the geometry of a production model. The math shown is exact for the vectors you type; the judgement of what counts as “similar enough” still depends on your model and task.
How it works
- Cosine similarity = dot(A, B) / (|A| × |B|), ranging from -1 to 1.
- Cosine distance = 1 − similarity; the angle is arccos(similarity) in degrees.
- Also reports dot product, magnitudes, Euclidean and Manhattan distance.
- Runs entirely in your browser — the vectors never leave the page.
Frequently asked questions
What is cosine similarity?
Cosine similarity measures the angle between two vectors, ignoring their length. It ranges from 1 (pointing the same direction) through 0 (perpendicular) to -1 (opposite), and is computed as the dot product of the two vectors divided by the product of their magnitudes. Because it looks only at direction, two documents about the same topic score as similar even when one is far longer than the other.
Cosine similarity or Euclidean distance for embeddings?
Cosine compares direction; Euclidean compares straight-line distance, which includes magnitude. Many embedding models already output normalized vectors (length 1), and for unit vectors the two are monotonically related — they produce the same ranking of nearest neighbours. Use cosine when magnitude is noise, which is the usual case for text embeddings; use Euclidean when the magnitude itself carries meaning.
What is cosine distance?
Cosine distance is 1 minus cosine similarity, which turns the similarity into a distance where 0 means identical direction and 2 means opposite. Vector databases often store distance rather than similarity so that “smaller is closer,” which matches how nearest-neighbour search and indexes expect to rank results.
Why does cosine similarity ignore magnitude?
Dividing by both magnitudes normalizes the vectors to unit length before comparing them, so only the angle between them remains. That is exactly what you want for text embeddings: a longer passage produces a larger vector without being more relevant, so you care that it points the same way, not that it is bigger.