Skip to content
Salyro
Tool

Cosine similarity calculator

Cosine similarity, dot product and Euclidean distance between vectors you paste — two, or a matrix of every pair. Runs in your browser.

What it does

Paste vectors and it compares them. With two, it gives their cosine similarity, cosine distance, dot product, Euclidean distance and each one's length. With three or more, up to 50, it gives a matrix of every pair by the measure you choose, and names the pair most alike.

Try it: two vectors, four labelled vectors as CSV, or vectors that point the same way at different lengths, where the dot product and cosine disagree.

What it reads

  • JSON: one vector, a list of vectors, or objects with a vector, embedding or values field and a label, id, name, text or title.
  • An embeddings API response, pasted as it came back: OpenAI's data[].embedding, including encoding_format: "base64", and Gemini's embedding.values or embeddings[].values. Nothing is called; the tool reads what you paste.
  • Rows: CSV, TSV or space-separated numbers, with an optional label first and an optional header.

Every vector needs the same number of dimensions. The arithmetic is done in double precision, whatever precision the vectors were stored in.

The formulas

  • Cosine similarity: cos(a, b) = (a · b) / (‖a‖ ‖b‖). It runs from −1 (opposite) through 0 (orthogonal) to 1 (the same direction), and ignores length. It is undefined for a vector of zeros, and the tool says so rather than showing 0.
  • Dot product: a · b = Σ aᵢ bᵢ. It grows as the angle narrows and as the lengths grow.
  • Euclidean distance: ‖a − b‖ = √Σ (aᵢ − bᵢ)². Smaller is closer.

For vectors normalised to length 1 the three rank pairs the same way: the dot product equals the cosine, and the distance is √(2 − 2·cos). Many embedding models return normalised vectors, which is why a search index may use any of them.

What it does not do

It does not make embeddings: it compares vectors you already have. Salyro does not serve embeddings, and nothing you paste is sent to it or anywhere else.

Where the numbers come from

This tool works only on what you enter. It uses no external data and runs entirely in your browser.