K-Map Solver: Minimize Boolean Expressions with Karnaugh Maps Online
Learn how to use the free online K-Map Solver to minimize Boolean expressions on 2–4 variable Karnaugh maps, with automatic grouping via the Quine–McCluskey algorithm and minimized SOP output.
Free Interactive Tool
K-Map Solver
Solve and minimize Boolean expressions on 2-4 variable Karnaugh maps with grouped prime implicants.
Table of Contents
If you have ever spent forty minutes circling ones on a Karnaugh map only to end up with an expression that still had a redundant literal in it, you already know why this tool exists. The K-Map Solver takes the minterms of any 2, 3, or 4-variable Boolean function, draws the map for you, finds every prime implicant with the Quine–McCluskey algorithm, and returns the minimized sum-of-products expression in seconds.
Everything runs locally in your browser. There is no signup, no upload of your homework to somebody's server, and no waiting on a queue — the solver is pure client-side JavaScript, which also means it works offline once the page has loaded.
In this guide we will walk through how the tool works, refresh the theory that makes Karnaugh maps tick, and work through a complete example so you can check the solver against a problem you can verify by hand.
Why Use the K-Map Solver?
- Correctness you can trust. Manual grouping is error-prone, especially on 4-variable maps where groups can wrap around the edges. The solver computes prime implicants exhaustively with Quine–McCluskey, so no valid group is ever missed.
- Instant feedback while learning. Instead of waiting until your exam results come back, you can test a grouping hypothesis immediately and see the exact minimal cover the algorithm picks.
- Don't-care support built in. Real circuit specifications often include "don't matter" conditions. The solver treats don't-cares the textbook way: they may be absorbed into groups but never need to be covered on their own.
- Color-coded groups on the map. Each selected implicant is highlighted with its own color, so you can see exactly which cells each product term in the final expression covers.
- Copyable SOP output. The minimized expression is rendered in standard notation (A'B + AC style) and can be copied to the clipboard in one click for your notes, your lab report, or your HDL file.
- Free and private. No account, no limits, and nothing leaves your machine.
Key Features
| Feature | What It Does |
|---|---|
| Variable count selector | Choose 2, 3, or 4 variables (A–D); the grid re-renders instantly |
| Minterm input | Enter minterms as a comma-separated list like 0,1,3,5,7 |
| Don't-care input | Optional list of don't-care terms, handled per standard minimization rules |
| Gray-code grid | Rows and columns follow reflected Gray code so adjacent cells differ by one bit |
| Prime implicant grouping | Quine–McCluskey finds every prime implicant; essential ones are selected first |
| Minimal cover selection | A greedy cover step finishes the job when essentials alone are not enough |
| Minimized SOP output | The final sum-of-products expression with one-click copy |
Two details are worth calling out. First, the grouping you see on the map is not a heuristic sketch — it is the actual set of implicants chosen by the cover algorithm, which means the expression you copy is genuinely minimal for the inputs you gave. Second, input validation is strict in a helpful way: if you type a minterm that is out of range for the chosen variable count, or if the same index appears in both the minterm and don't-care lists, you get a clear error message instead of a silently wrong answer.
How to Use the K-Map Solver
- Open the K-Map Solver and pick your variable count: 2, 3, or 4.
- Type your minterms into the minterm field, for example 0,1,3,5,7.
- If your specification includes don't-care conditions, list them in the don't-care field.
- Press Solve. The K-map renders with each cell showing 1, 0, or X, and the groups appear as colored outlines.
- Read the minimized SOP expression from the result panel and copy it wherever you need it.
Understanding Karnaugh Maps
A Karnaugh map is a truth table folded into a grid where physical adjacency means logical adjacency. The trick that makes it work is Gray code ordering: the rows and columns are labeled in reflected binary sequence (00, 01, 11, 10) rather than counting order, which guarantees that any two neighboring cells — including cells on opposite edges, since the map conceptually wraps around — differ in exactly one variable.
That single-bit difference is the whole engine of simplification. When you circle a group of adjacent ones, every variable that changes inside the group is redundant and drops out of the product term:
- A group of 2 cells eliminates one variable.
- A group of 4 cells eliminates two variables.
- A group of 8 cells eliminates three variables.
Valid groups must be rectangles whose sides are powers of two, and the larger the group, the cheaper the resulting term. Don't-care cells are wildcards: you may include them in a group to make it bigger, but you are never obligated to cover them, because the function's value there does not matter.
Why Quine–McCluskey? Visual grouping becomes fragile at 4 variables and impractical beyond it. The Quine–McCluskey algorithm is the systematic equivalent: it repeatedly merges minterms that differ in one bit (exactly what your eye does on the map) until no more merges are possible. Whatever survives is a prime implicant. The solver then identifies essential prime implicants — those that are the only cover for some minterm — and finally runs a minimal cover selection over the remaining minterms. The result is provably minimal, matching the outcome a perfect human grouper would reach.
Worked example. Consider F(A,B,C,D) = Σm(0,1,3,5,7) — a classic from digital logic textbooks. The eight don't-free minterms are 0000, 0001, 0011, 0101, and 0111. On the map:
- Minterms 1, 3, 5, and 7 (0001, 0011, 0101, 0111) all share A=0 and D=1, so they merge into the quad that yields A'D.
- Minterms 0 and 1 (0000, 0001) differ only in D, yielding A'B'C'.
The solver finds exactly these two prime implicants, both essential, and returns F = A'D + A'B'C' — five literals instead of the five full four-literal product terms the canonical SOP would need. That is the kind of reduction that turns a mess of gates into two ANDs and an OR.
Practical Use Cases
Digital circuit design
When you derive a function from a specification — sensor thresholds, state decoder logic, address select lines — the canonical form is almost never what you want to build. Minimizing before synthesis means fewer gates, fewer literals per gate, and shorter critical paths, which matters on slow logic families or crowded CPLDs.
Exam study and homework checking
Karnaugh maps are a fixture of digital logic courses. Use the solver as an answer key: solve the problem on paper, then enter your minterms and compare. If your expression differs, the color-coded groups show you exactly which grouping you missed — often a wrap-around group or a chance to use a don't-care you ignored.
FPGA and CPLD optimization
Modern synthesis tools do their own minimization, but understanding what a minimal form looks like helps you write better HDL and interpret synthesis reports. Checking a hand-derived next-state equation against the solver before committing it to RTL catches literal-count mistakes that compile fine but waste macrocells or LUT inputs.
Validating truth-table derivations
Pair the solver with a truth table you have just built: feed the rows where the output is 1 into the minterm field, add any impossible input combinations as don't-cares, and read off the minimal expression. It is the fastest path from behavior to logic.
Best Practices
- Always include don't-cares when they exist. They can only help — they enlarge groups for free and never force extra terms.
- Double-check your minterm list against the truth table. The solver minimizes exactly what you type; a transposed index silently changes the function.
- Prefer fewer, larger groups conceptually. Even though the algorithm handles it, understanding why an 8-cell group beats three 4-cell groups builds the intuition exam questions test.
- Remember the map wraps around. Left-edge columns are adjacent to right-edge columns, and top rows to bottom rows — a common source of missed groups when solving by hand.
- Verify the result by evaluation. For a quick sanity check, evaluate the minimized expression and the original minterm list on a few input combinations; they must agree wherever the output is defined.
- Keep the canonical form in your notes. The minimized expression is what you build, but the minterm list is the specification — store both.
Start Simplifying Today
Grab the function you are working on, head to the K-Map Solver, enter your minterms, and watch the groups assemble themselves. Whether it is tonight's problem set or next week's schematic, the two minutes you spend will save you an hour of circling — and give you an answer you can actually trust.
Related Tools You Might Like:
- Truth Table Generator — build the truth table first, then feed its 1-rows in as minterms
- Gray Code Converter — understand the reflected-binary ordering used to lay out K-map axes
- Bitwise Calculator — evaluate AND/OR/XOR expressions once your circuit is minimized
Happy simplifying!