Jaccard Similarity Calculator
- The union counts everything in either set: 50 + 60 - 30 = 80 elements - the overlap is subtracted once so it is not double-counted.
- Divide the overlap by the union: 30 / 80 = 0.375 - the Jaccard index, running from 0 for sets with nothing in common to 1 for identical sets.
- The matching distance is 1 - 0.375 = 0.625 - the form used when the index feeds a clustering threshold or a near-duplicate cutoff.
The Jaccard Similarity Calculator measures how much two sets have in common by computing the Jaccard index: the size of their intersection divided by the size of their union. Enter your two sets and the calculator returns that single number, which runs from 0 for sets with nothing in common to 1 for identical sets. For example, sets of 50 and 60 elements that share 30 have a union of 80 and a Jaccard similarity of 0.375. Twin sets of 20 that share 12 score 0.429. The tool can also report the Jaccard distance, which is 1 minus the index.
The method is the accepted standard for this kind of comparison because the Jaccard index is a simple, well-defined ratio that counts shared elements against everything present in either set, so it is not inflated by the size of the sets alone. The Jaccard distance, 1 minus the index, is a true metric, which is why it is the form used for clustering and near-duplicate thresholds. The index itself dates to Paul Jaccard, who introduced it in 1901 for comparing the species composition of alpine flora samples. This page shows the formula, step-by-step workings, worked examples and sources, so you can check every result rather than just read it.
Worked examples
Half-overlapping sets
Sets of 50 and 60 sharing 30 elements have a Jaccard similarity of 0.375. (30 · 50 · 60)
| Jaccard similarity | 0.375 |
| Union size | 80 |
| Jaccard distance | 0.625 |
| Similarity share | 37.5% |
Twin sets, small overlap
Twin sets of 20 sharing 12 score 0.429. (12 · 20 · 20)
| Jaccard similarity | 0.429 |
| Union size | 28 |
| Jaccard distance | 0.571 |
| Similarity share | 42.9% |
Large sets
Sets of 90 and 120 sharing 45 score 0.273 - a big overlap can still be a modest similarity. (45 · 90 · 120)
| Jaccard similarity | 0.273 |
| Union size | 165 |
| Jaccard distance | 0.727 |
| Similarity share | 27.3% |
What the Jaccard index measures
The Jaccard index answers a simple question: of everything that appears in either set, how much actually appears in both? You take the number of items in the intersection — the members the two sets share — and divide it by the number of items in the union, the combined total of distinct members. That single ratio is the Jaccard index, and it is the standard way to score set similarity for tags, text shingles, shopping baskets and species lists. A jaccard similarity calculator applies this division for you, but the logic behind the number is worth holding onto, because it explains why the results look the way they do.
Because the union is always at least as large as the intersection, the score runs from 0 to 1. Identical sets score 1, since the intersection and the union are the same size. Disjoint sets score 0, since nothing is shared. Most real comparisons land somewhere between. Consider two sets of 50 and 60 elements that share 30. The union is 50 + 60 − 30 = 80, and 30 ÷ 80 gives a Jaccard similarity of 0.375. A second example makes the same point on a smaller scale: twin sets of 20 that share 12 have a union of 28 and a score of 0.429. Notice that a large overlap in absolute terms can still be a modest score, because the index measures overlap as a share of everything present in either set, not as a share of one set alone.
The index has a long history. Paul Jaccard introduced it in 1901 for comparing the species composition of alpine flora samples, where the question was how much of the combined plant list two samples had in common. The same arithmetic now powers tag matching, shingle comparison in near-duplicate detection, basket analysis and any other task where you need to compare two collections of distinct items.
The complement of the index, the Jaccard distance, is 1 minus the index. It is a true metric, and it is the form used for clustering and near-duplicate thresholds. A pair of sets with an index of 0.375 has a distance of 0.625, which you can compare against a cutoff to decide whether two documents, listings or records are close enough to treat as the same.
How it is calculated
The Jaccard index of two sets is the size of their intersection divided by the size of their union. That one sentence is the whole formula, but the order of operations matters: build the union first, then divide. A jaccard similarity calculator does exactly this, and doing it by hand is a good way to see why the union is not simply the two set sizes added together.
The union is A + B − intersection. The subtraction is the step people skip. Every shared element gets counted once in A and again in B, so adding the raw sizes double-counts the overlap. Take sets of 50 and 60 elements that share 30. Adding the sizes gives 110, but the 30 shared elements were counted twice, so the union is 50 + 60 − 30 = 80. Now divide the intersection by the union: 30 / 80 = 0.375. That is the Jaccard similarity of the pair.
The same three-step routine handles any pair. Twin sets of 20 elements that share 12 give a union of 20 + 20 − 12 = 28, and 12 / 28 = 0.429. A pair with a smaller overlap relative to its size lands lower. If the intersection is 15 and the union works out to 55, the index is 15 / 55 = 0.273. Notice that the answer always falls between 0 and 1, because the intersection can never be larger than the union. Identical sets score 1, since everything in one is in the other and intersection equals union. Disjoint sets score 0, since the intersection is empty.
The index is only half the story. The Jaccard distance is 1 minus the index, and it is a true metric, which is why it is the form used for clustering and near-duplicate thresholds. For the 0.375 pair the distance is 0.625; for 0.429 it is 0.571; for 0.273 it is 0.727. A threshold stated as a distance is therefore the mirror image of one stated as a similarity, so check which direction a cutoff runs before you apply it.
The measure is not new. Paul Jaccard introduced the index in 1901 for comparing the species composition of alpine flora samples, and the same ratio now turns up wherever sets are compared. The arithmetic has not changed: union first, intersection over union, and read the result on a scale from 0 to 1.
Jaccard similarity vs distance
The Jaccard index and the Jaccard distance are two views of the same comparison, and the arithmetic that links them is a single subtraction. The Jaccard index of two sets is the size of their intersection divided by the size of their union. The Jaccard distance is simply 1 minus the index. If two sets have a similarity of 0.375, their distance is 0.625. Nothing else changes: the distance carries exactly the same information as the index, just expressed from the opposite end of the scale.
A worked example makes the relationship concrete. Take sets of 50 and 60 elements that share 30. The union is 80, so the similarity is 30 divided by 80, or 0.375, and the distance is 1 minus 0.375, or 0.625. The same rule applies at the extremes: identical sets score 1 (distance 0), and disjoint sets score 0 (distance 1). Twin sets of 20 elements sharing 12 have a union of 28 and a similarity of about 0.429, so their distance is about 0.571. A jaccard similarity calculator can report either figure, but knowing which one you are looking at matters, because the two behave differently when you start comparing many items at once.
The reason the distance form is the one that feeds clustering is that the Jaccard distance, 1 minus the index, is a true metric. In practical terms, that means it behaves like an ordinary distance: it is never negative, it is zero only when the sets are identical, it is symmetric, and — the property that similarity itself lacks — it satisfies the triangle inequality. The triangle inequality says that going from set A to set C directly is never longer than going through some intermediate set B. Similarity scores do not obey this rule, which is why algorithms that rely on geometric notions of closeness are built on the distance form instead.
This is also why the Jaccard distance is the form used for clustering and near-duplicate thresholds. When you group documents, products, or records by how much their feature sets overlap, the clustering method needs a consistent notion of separation, and the metric properties of the Jaccard distance supply it. Thresholds are usually set on the distance as well: a rule like "flag pairs with distance below 0.2" is equivalent to "flag pairs with similarity above 0.8," but stating it as a distance keeps it in the same units the clustering step uses. The index itself dates to Paul Jaccard, who introduced it in 1901 for comparing the species composition of alpine flora samples — a reminder that the measure was built for set overlap long before it became a tool for grouping data at scale.
- Similarity: intersection ÷ union. Distance: 1 − similarity.
- Sets of 50 and 60 sharing 30: union 80, similarity 0.375, distance 0.625.
- Twin sets of 20 sharing 12: similarity about 0.429, distance about 0.571.
- Identical sets: similarity 1, distance 0. Disjoint sets: similarity 0, distance 1.
- The distance form is a true metric and satisfies the triangle inequality, which is why clustering and near-duplicate thresholds use it.
Where it is used
The Jaccard index of two sets is the size of their intersection divided by the size of their union, and that simple ratio turns out to be useful anywhere you need to compare two collections by what they share rather than by how big they are. A jaccard similarity calculator makes those comparisons repeatable and quick, which matters most when the sets are large or when you are checking many pairs.
Near-duplicate detection is the best-known application. Documents, web pages, or product listings are broken into overlapping word or character shingles, and each shingle becomes a set element. Two pages that share most of their shingles score close to 1; unrelated pages score close to 0. Because the index ignores how many shingles are unique to each side, a long article and a short excerpt of it can still be flagged as related. For thresholding and clustering, practitioners usually work with the Jaccard distance, which is 1 minus the index and is a true metric, so it behaves well in clustering algorithms and near-duplicate cutoffs.
Recommender systems use the same idea to measure overlap between users or items. If two shoppers bought largely the same products, their purchase sets have a high Jaccard similarity, and that overlap can feed a recommendation. Market-basket analysis applies it to item sets: instead of asking only how often items appear together, you can ask how much of the combined basket they account for. The index also has an ecological root. Paul Jaccard introduced it in 1901 for comparing the species composition of alpine flora samples, and ecologists still use it to compare which species two sites share relative to the total species pool across both.
A few worked numbers show the scale. Sets of 50 and 60 elements sharing 30 have a union of 80 and a Jaccard similarity of 0.375. Twin sets of 20 sharing 12 score 0.429. Identical sets score 1 and disjoint sets score 0. That bounded, size-independent reading is why the measure travels so well across domains.
The Jaccard index is not always the right tool. When the size of each set matters, or when you care about how much of one set is covered by another rather than how much of the combined total they share, the overlap coefficient is often a better fit. When elements carry weights or frequencies, cosine similarity typically serves better because it accounts for magnitude rather than presence alone. Use Jaccard when you want a clean, symmetric answer to the question of how much two sets have in common relative to everything either one contains.
FAQs
What is Jaccard similarity?
Jaccard similarity is the size of the intersection of two sets divided by the size of their union. It gives a similarity score between 0 and 1, where higher values mean the sets share more of their combined contents. Because it compares overlap to total combined size, it reflects how alike two sets are overall.
How do you calculate Jaccard similarity?
Divide the overlap by the union. If two sets share 30 of a combined 80 elements, the Jaccard similarity is 30 / 80 = 0.375. Count the elements in both sets together for the union, count the elements in both at once for the intersection, then divide the intersection by the union.
What is Jaccard distance?
Jaccard distance is one minus the Jaccard similarity. In the example above, with a similarity of 0.375, the Jaccard distance is 0.625. It is used as a dissimilarity measure in clustering, where larger values mean the sets are less alike. It ranges from 0 to 1, moving opposite the similarity score.
What does a Jaccard similarity of 1 mean?
A Jaccard similarity of 1 means the sets are identical: every element of each set is in the other. Their intersection equals their union, so dividing the intersection by the union gives 1. No element appears in only one set. A score of 0, by contrast, would mean the sets share nothing.
How is Jaccard different from the overlap coefficient?
The overlap coefficient divides by the smaller set, so it reads 1 whenever one set contains the other, even if the sets differ greatly in size. Jaccard divides by the union and penalises size differences, so it stays below 1 unless the sets are identical. Jaccard therefore gives a stricter view of similarity between sets of unequal size.
Where is Jaccard similarity used?
Jaccard similarity is used in document near-duplicate detection, recommendation, market-basket analysis and ecological community comparison. In each case it measures how much two sets share relative to their combined size, which suits comparing word sets, item sets, or species lists and judging how alike they are.