A free tool for 2 to 5 variables

Karnaugh map solver.

Click cells to set 1, 0, or X (don't-care). The minimal sum-of-products (SOP) is computed live, with each prime implicant drawn as a loop on the map — wrap-around groups included. A free tool for boolean simplification and digital-logic minimization.

Need a refresher?
How this works

From map to formula.

A Karnaugh map is a visual aid for boolean simplification — it lays out a logic function so that cells that differ in exactly one variable sit next to each other, including across the top–bottom and left–right edges, which wrap. Any rectangle of 1s whose side lengths are powers of two is a valid implicant of the underlying sum-of-products, and the bigger the rectangle, the simpler the term.

Under the hood, this page runs Quine–McCluskey to enumerate every prime implicant, then Petrick's method to pick the smallest covering set when essentials don't carry the whole load. Don't-cares are folded in to grow groups when it helps, and dropped when it doesn't — the same logic minimization a digital-design textbook walks you through by hand.

Worked example

Solving a 4-variable K-map.

Watch the corners-and-center pattern collapse into two terms. Same problem you'd see in a digital-logic homework set — same answer, in two seconds.

C′C′CC
D′DDD′
A′A′AA
B′BBB′
10
01
03
12
04
15
17
06
012
113
115
014
18
09
011
110
  1. 1
    Start with the minterms. f(A,B,C,D) = Σm(0, 2, 5, 7, 8, 10, 13, 15) — eight 1-cells out of sixteen.
  2. 2
    Plot them on the K-map. Rows are labeled AB in Gray order; columns are CD. Each cell's minterm index is in the top-left corner.
  3. 3
    Spot the rectangles. The center 2×2 — m(5, 7, 13, 15) — has B = 1 and D = 1, so it collapses to BD. The four corners — m(0, 2, 8, 10) — have B = 0 and D = 0; they're one group because the edges wrap, collapsing to B'D'.
  4. 4
    Combine. The minimal sum-of-products is B'D' + BD. Four literals total — half what a naïve cell-by-cell expansion would need.
  5. 5
FAQ

Common questions.

What is a Karnaugh map?

A Karnaugh map (or K-map) is a graphical method for simplifying a boolean function. Cells are arranged so that adjacent cells differ in exactly one variable, which means any rectangular group of 1s whose side lengths are powers of two represents a simpler boolean term. K-maps are the standard visual technique taught in digital-design and discrete-math courses for minimizing logic expressions of up to five or six variables.

How do I read this K-map?

Row and column labels use Gray code order — 00, 01, 11, 10 — so neighboring rows and columns differ in only one bit. For a 4-variable map, rows encode AB and columns encode CD; each cell shows its minterm index in the corner. Click a cell to cycle through 0, 1, and X (don't-care).

What does a don't-care (X) mean?

A don't-care is an input combination whose output you don't care about — usually because the combination can't occur in the real circuit, or because downstream logic handles either result the same way. The solver is free to treat each X as a 0 or a 1, whichever makes the resulting groups bigger. Don't-cares often dramatically shrink the final expression.

Why do groups wrap around the edges?

Because the leftmost and rightmost columns differ in exactly one variable, and so do the top and bottom rows. That means cells on opposite edges are adjacent in the boolean sense, even though they aren't visually next to each other. A K-map is topologically a torus: the four corners can form a single quad, and the four cells in the first and last columns can form a 1×4 block.

How does the 5-variable case work?

With five variables you get 32 cells, which is too many for a single 4×4 grid. The solver shows two stacked 4×4 boards — one for E = 0, one for E = 1. Cells in the same position on each board are adjacent (they differ only in E), so a group can span both boards. The minimization algorithm handles cross-board adjacency automatically.

How is this different from Quine–McCluskey by hand?

It isn't — the algorithm is the same. Quine–McCluskey tabulates the minterms, repeatedly combines adjacent ones into prime implicants, and then selects a minimal cover (using Petrick's method when essentials alone can't cover everything).

The team behind wrap.

We built this solver because we built a game on the same math. wrap is a two-player puzzle where the edges of the board connect — quad of four wins.