Cosine Similarity Calculator (Embedding Vector Comparison)
Compute cosine similarity, dot product, and Euclidean distance between two vectors online. Perfect for debugging LLM embeddings, semantic search, and RAG pipelines. 100% local — vectors never leave your browser.
Last updated:
Cosine similarity
Dot product
0.766400
Euclidean (L2)
0.097980
Manhattan (L1)
0.260000
Angular distance (normalized)
0.031560
|A|
0.900444
|B|
0.855336
Dimensions: 8 · 8. Cosine is bounded to [-1, 1]; Euclidean and Manhattan are unbounded distances.
Input format: JSON array like [0.1, -0.2, 0.3], or plain numbers separated by whitespace / commas / newlines. Everything runs locally in your browser.
Paste two vectors (JSON arrays) to compute their cosine similarity — a value between -1 and 1 measuring the angle between them, independent of magnitude. Also supports batch N×N similarity for multiple vectors with a heatmap. Ideal for embedding-based retrieval.
Tips & Best Practices
- ▸Cosine similarity ignores vector magnitude — only direction matters. Use dot product instead if magnitude carries meaning.
- ▸For dense embeddings (OpenAI, Cohere, sentence-transformers), typical 'similar' scores are 0.7-0.95; below 0.5 usually means unrelated.
- ▸For very large collections, don't compute pairwise on the fly — use FAISS, HNSW, or a vector database.
Frequently Asked Questions
What does cosine similarity actually measure?
Cosine similarity is the cosine of the angle between two vectors. It ranges from -1 (opposite direction) through 0 (orthogonal / unrelated) to 1 (same direction). It ignores magnitude and only compares direction, which is why it is the default similarity metric for text embeddings.
When should I use cosine vs dot product vs Euclidean distance?
Use cosine when your vectors are not normalized and you only care about direction (typical text embeddings from OpenAI, Cohere, Voyage). Use dot product when vectors are already L2-normalized — it's mathematically identical to cosine but faster. Use Euclidean when magnitude matters (image embeddings, some clustering scenarios).
Do vectors need to be the same dimension?
Yes. Similarity is only defined between vectors of the same dimension. If you paste vectors of different lengths the tool will show an explicit error with the mismatched sizes.
How large a vector can I paste?
The tool has been tested with 3072-dimension vectors (OpenAI text-embedding-3-large). Anything up to ~10K dimensions computes instantly. For matrix mode with N vectors, the N×N result grows quadratically, so keep N under ~200 for a smooth UI.
Related Tools
Text Chunker
Split long text into overlapping chunks for embedding and RAG pipelines. Preview recursive, paragraph, sentence, or fixed strategies with live token counts. Runs 100% in your browser.
AI Cost Calculator
Estimate monthly LLM API cost across GPT-4o, Claude 3.5, Gemini, DeepSeek and more. Compare providers side-by-side with prompt caching and batch discounts.
Token Counter
Estimate the number of tokens in your prompt for GPT-4, GPT-3.5, Claude, and Gemini. Predict API costs before you spend.
JSON Formatter
Format, beautify, and validate JSON online. Free, fast, and 100% local — your data never leaves your browser.
JSON Validator
Validate JSON online with instant error location and structure statistics (depth, keys, node types). 100% local — your JSON never leaves the browser.
JSON → TypeScript
Convert JSON to TypeScript interfaces instantly. Generate strongly-typed TS types from any JSON sample.