Vector Similarity Calculator
Compare embedding vectors locally with similarity matrices and a 2D projection
About
Paste JSON arrays or comma-separated vectors to calculate pairwise metrics and inspect a 2D projection. All calculations run locally with no API calls.
Examples
Orthogonal cosine pair
calculateVectorSimilarity("1,0\n0,1", "cosine")matrix [[1, 0], [0, 1]]Perpendicular unit vectors score 0 cosine with 1s on the diagonal.
Zero-vector warning
calculateVectorSimilarity("0,0\n1,0", "cosine")matrix[0][1] = 0 + "zero vector" warningCosine is undefined for a zero vector, so the tool reports 0 and warns explicitly.
About this tool
Vector Similarity Calculator compares embedding-style vectors with calculateVectorSimilarity(input, metric, projectionMethod): inputs parse from JSON arrays or comma/whitespace/newline-separated rows via parseVectors, mismatched dimensions return an explicit error, and results include a full pairwise matrix plus a 2D projection.
Metrics are cosine (cosineSimilarity, 0 for zero vectors with a warning), euclidean distance, and raw dot product via vectorDistance. Projections use projectVectors with first-two coordinates or a deterministic PCA path (power iteration with fixed sign) that returns identical output across calls.
The matrix is square (n x n) with 1s (cosine) down the diagonal — C(n,2) unique off-diagonal pairs — and single-vector or empty input yields guidance warnings or an enter-at-least-two-vectors error. All math runs client-side.
How to use this tool
Paste two or more vectors
Enter one vector per line (1,0 / 0,1) or a JSON array like [[1, 2], [3, 4]] — all rows need equal dimensions.
Pick cosine, euclidean, or dot
Cosine scores direction (orthogonal = 0), euclidean scores distance, dot scores raw alignment.
Read the matrix and projection
Check pairwise scores in the square matrix and the first-two or PCA scatter for cluster shape.
Use cases
Sanity-checking embeddings
Confirm similar texts score near 1 cosine and unrelated ones near 0 before indexing.
Comparing distance metrics
See how cosine, euclidean, and dot rank the same vector pairs differently.
Previewing cluster layout
Project small vector sets with first-two or PCA coordinates for a quick scatter view.
Common mistakes
Mistake:Passing ragged rows and expecting partial scores.
Fix:Any dimension mismatch returns an error with an empty matrix — pad or truncate rows to equal length first.
Mistake:Reading cosine of a zero vector as meaningful.
Fix:Zero vectors always report 0 with a warning; re-embed or drop them instead of ranking on that score.
Mistake:Expecting the matrix to list only unique pairs.
Fix:The matrix is square n x n including the diagonal — count C(n,2) unique off-diagonal pairs (6 for 4 vectors) yourself.
Frequently asked questions
What does this tool do?
It compares vectors with calculateVectorSimilarity: JSON or line-based input via parseVectors, cosine/euclidean/dot metrics in a square n x n matrix, plus first-two or deterministic PCA projection via projectVectors.
What happens with mismatched dimensions or zero vectors?
Mismatched dimensions return an explicit same-dimensions error with an empty matrix; a zero vector reports cosine 0 with a warning that the score is undefined.
Is my vector data uploaded or stored?
No. Parsing, similarity math, and PCA all run locally in your browser.
Why is the matrix square instead of unique pairs?
The matrix includes the full n x n grid with the diagonal, so for 4 vectors you read C(4,2) = 6 unique off-diagonal pairs out of 16 cells.
Related guides
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
AI Function Calling Schema Generator
Generate function calling JSON schemas from TypeScript interfaces
Algorithm Arena & Data Structure Visualizer
Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.
Ansible Playbook Generator
Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML