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:
CommentsPaste 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.
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.
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.
Try Next
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.
Related Tools
Context Window Checker
Check whether your prompt fits a model's context window before you send it. Estimates prompt tokens, reserves room for the response, and shows remaining headroom across GPT-4o, o1, Claude, Gemini, DeepSeek and more. 100% local.
Prompt Token Breakdown
Break a prompt into segments and see how many tokens — and how much cost — each part uses. Find the heaviest section (system, few-shot examples, or user input) so you know exactly what to trim. 100% local.
Schema → Tool Definition
Turn a sample JSON payload into function-calling / tool definitions for OpenAI, Anthropic, and Gemini — side by side. Strict-mode toggle adds required + additionalProperties: false. 100% local, paste straight into your tools array.
Chat Messages Validator
Validate a Chat Completions messages array before you send it — checks roles (system/user/assistant/tool), required content, and common mistakes that cause a 400. 100% local.
Prompt Template Tester
Write a prompt with {{variable}} placeholders, fill in values, and preview the final prompt. Detects every variable and flags any you left unfilled. 100% local.
Prompt Diff
Compare two versions of a prompt line by line and see the token delta between them — so you know exactly what changed and whether an edit made the prompt cheaper or more expensive. 100% local.