digiwleea Tools
Learn Open the lab →

Karnaugh map solver

A Karnaugh map is a grid that arranges a logic function's outputs so adjacent 1s can be grouped by eye, giving its simplest sum-of-products form without algebra. Toggle a 2, 3, or 4 variable Karnaugh map by clicking each cell (it cycles 0, 1, then a don't-care X), or type a list of minterms instead. The solver returns the minimized sum-of-products boolean expression right away, and it uses any don't-cares to make the groups bigger and the answer shorter.

How to use it

Worked example

Choose 3 variables and set the four cells where A = 1 to 1. Those are minterms 4, 5, 6, and 7 (binary 100, 101, 110, 111). On the map they form one solid block of four, the entire bottom row where the row header reads 1 for A.

Inside that block of four, B takes both values (0 and 1) and C takes both values (0 and 1), so neither B nor C decides the output. Only A is constant at 1 across the whole group. A group of four cells removes two variables, and what is left is the single literal that did not change. So the minimized result is just F = A: the output is 1 exactly when A is 1, no matter what B and C do. That four-term truth table collapses to one letter.

How Karnaugh map minimization works

A Karnaugh map is a truth table folded into a grid with one special property: neighbouring cells differ in exactly one input bit. That is why the row and column headers run in Gray-code order (00, 01, 11, 10) rather than plain binary, so a step in any direction flips a single variable.

Because neighbours differ by one bit, a rectangular group of 1s whose size is a power of two (1, 2, 4, 8, ...) always shares a fixed set of variables, while the rest cancel. Each group becomes one product term made only of the variables that stay constant: a variable held at 1 appears as itself, one held at 0 appears primed, and a variable that changes inside the group drops out. The bigger the group, the fewer literals survive.

A group that cannot grow any larger is a prime implicant. Some 1s can only be covered by a single prime implicant, which makes that group essential, so the solver always takes the essential ones first, then greedily adds whatever covers the most of the remaining 1s with the fewest literals. A don't-care can join a group when that helps, but it never has to be covered on its own, which is how a stray X can let a group double in size and shrink the final expression.

Frequently asked

What is a Karnaugh map?

A Karnaugh map is a grid that arranges a truth table so that adjacent cells differ in exactly one input bit. Grouping adjacent 1s in powers of two lets you read off a minimized boolean expression without algebra.

How does this K-map solver minimize?

It finds every prime implicant of the ON-set and don't-cares, then selects a small cover using the essential prime implicants first. The result is a minimized sum-of-products expression with each group written as a product term.

What is a don't-care in a Karnaugh map?

A don't-care, often written X, is an input combination whose output never matters. The solver is free to treat each one as 0 or 1, whichever makes the groups larger and the final expression simpler.

Once you have the minimized expression, build it for real: open the lab and wire the gates from transistors, or read the theory on Karnaugh maps and boolean algebra.

Related tools: truth table generator and boolean simplifier.

Open the lab →

Embed this tool

Free to embed in your course page, blog, or notes: just keep the credit link under the widget. Paste this where you want it:

<iframe src="https://digiwleea.wleeaf.dev/embed/tool/?w=kmap" width="100%" height="560" style="border:0;border-radius:12px;max-width:720px" title="Karnaugh map solver" loading="lazy"></iframe>