Use this calculator to compute the Cartesian product of two sets — every ordered pair with a first element from set A and a second from set B. Paste your lists into Data Set #1 and Data Set #2, then read the pairs in Output.

0 pairs

Use commas, spaces, or new lines to separate items in your input sets. Order matters: A × B is not the same as B × A.

What is a Cartesian Product?

In mathematics, the Cartesian product of two sets A and B, written A × B, is the set of all ordered pairs (a, b) where a is from A and b is from B. If A has m elements and B has n elements, then A × B has m × n pairs.

Unlike union, intersection, and difference, the Cartesian product builds combinations across sets rather than merging or filtering individual elements.

Cartesian Product

Cartesian product of two sets — every element of A paired with every element of B

The Cartesian product lists every way to pick one item from the first set and one from the second. Think of it as a complete grid of options.

For example, suppose a store offers shirt colors:

  • red, and
  • blue

and shirt sizes:

  • S,
  • M, and
  • L

Every color–size combination is:

  • (red, S), (red, M), (red, L),
  • (blue, S), (blue, M), and (blue, L)

That list is the Cartesian product of the two sets!

Try it!

Key properties

Order matters

Pairs are ordered: (a, b) is different from (b, a). Swapping the two input sets produces a different product (unless the sets are equal and you only care about pair content after reordering).

Empty set

If either set is empty, the product is empty. There is no way to form a pair when one side has no elements.

Duplicates

This calculator treats each input as a set: duplicate items in a list are counted once before pairs are generated.