Enter two finite sets to find their union, intersection, directional differences, and symmetric difference. Add a universal set to calculate complements. Duplicate values are removed, and everything runs privately in your browser.
Enter your sets
Separate elements with commas, semicolons, or new lines. Values are text labels, so 1 and 1.0 are different elements.
Example: red, green, blue4 unique elements
Empty input represents the empty set ∅.4 unique elements
U must contain every element of A and B.8 unique elements
Private by design: the sets are parsed and compared on this device. Inputs are not uploaded, saved, or included in the page URL.
Results
The number example is calculated below.
Set operation definitions and formulas
Union
A ∪ B = {x | x ∈ A or x ∈ B}
Every element found in either set, listed once.
Intersection
A ∩ B = {x | x ∈ A and x ∈ B}
Only elements shared by both sets.
Difference
A ∖ B = {x | x ∈ A and x ∉ B}
Elements of the first set that are absent from the second. Direction matters.
Symmetric difference
A △ B = (A ∖ B) ∪ (B ∖ A)
Elements in exactly one set, excluding the intersection.
Complement
Aᶜ = U ∖ A
Elements of the universal set U that are not in A.
Union cardinality
|A ∪ B| = |A| + |B| − |A ∩ B|
The shared elements are subtracted once because the first two counts include them twice.
Worked set operations example
Let A = {1, 2, 3, 5}, B = {2, 3, 4, 6}, and U = {1, 2, 3, 4, 5, 6, 7, 8}. The overlap is {2, 3}; values 1 and 5 belong only to A, while 4 and 6 belong only to B.
Operation
Result
Cardinality
A ∪ B
{1, 2, 3, 5, 4, 6}
6
A ∩ B
{2, 3}
2
A ∖ B
{1, 5}
2
A △ B
{1, 5, 4, 6}
4
Aᶜ = U ∖ A
{4, 6, 7, 8}
4
The identity check gives |A ∪ B| = 4 + 4 − 2 = 6, matching the six unique elements in the union.
Method, matching rules, and limits
The calculator splits each input at commas, semicolons, and line breaks; trims leading and trailing whitespace; normalizes equivalent Unicode compositions; and removes duplicates. Exact matching is the default. In case-insensitive mode, labels such as Blue and blue match, while the first spelling encountered is retained for display.
Set results preserve useful input order: union and symmetric difference start with qualifying A elements and then add qualifying B elements; complements follow U. The universal set is optional for the first five operations, but complements are shown only when U contains every element of A and B. Blank A or B input is a valid empty set.
Each input is limited to 20,000 characters and 1,000 unique elements. Result cards display the first 100 elements to keep very large inputs responsive; copy and CSV exports still include the complete calculated result. Quoted CSV parsing is not used, so commas, semicolons, and line breaks cannot be part of an element.