Karnaugh Map Solver (K-Map Calculator)
Simplify Boolean functions instantly using K-Maps, truth tables, Boolean expressions, minterms, or maxterms. Get exact SOP/POS results step by step.
How would you like to define your K-map?
Click cells to toggle between 0, 1, and X (don't care)
Simplified K-Map Result
Map Groupings
The function is constant; the entire map or no cells are grouped.
Simplified Expression
F = 0
Original Groups Breakdown
- Terms
- 0
- Literals
- 0
- Gates
- 0
Step-by-step trace
Gate-Level Circuit Diagram
Synchronized Truth Table
Updates automatically based on your Karnaugh Map input.
The PDF is a text summary of the solution. It does not include the K-Map, highlighted groups or circuit diagram.
How it works
From a boolean function to a minimized, gate-level circuit in four steps.
Choose your variables
Pick 2, 3, 4, or 5 variables to match the boolean function you're minimizing.
Enter your function
Type a boolean expression, list minterms or maxterms, or fill in the truth table directly.
Read the grouped map
Pairs, quads, and octets are outlined automatically as the solver finds the largest valid groups.
Get the minimized result
Review the simplified SOP or POS expression, the highlighted K-Map groups and the gate-level circuit, or export a PDF.
What you'll see
A preview of the tool's main views. Scroll to browse.
How to Use the Karnaugh Map Solver
The Karnaugh Map Solver helps you simplify Boolean functions with 2 to 5 variables. You can start with the form of the problem you already have instead of converting everything by hand. If you are new to the method, our guide on what a Karnaugh Map is explains how the grid, Gray-code adjacency, and basic simplification fit together.
Choose the number of variables, then enter the function using the K-Map, truth table, Boolean expression, minterms, or maxterms. These inputs represent the same Boolean function, so changes in one view are reflected in the others.
On the K-Map, click a cell to move between 0, 1, and X. Use X when the problem includes a don't-care condition.
If your function is given as minterms, you can enter a form such as:
Σm(1,3,5,7)
For maxterms:
ΠM(0,2,4,6)
You can also type a Boolean expression and use the generated truth table and K-Map to check the output for each input combination.
After entering the function, choose SOP or POS and view the simplified result.
K-Map Calculator Results
This K-Map Calculator shows more than a final Boolean expression. It also helps you see how the minimized result is connected to the map.
The output can include the simplified expression, highlighted K-Map groups, term and literal information, gate count, and a gate-level circuit diagram.
This is useful when you want to check not only the answer, but also how the answer was formed. A step-by-step trace of the Quine-McCluskey process behind the result is described further down this page.
SOP and POS Simplification
SOP (Sum of Products) works from the input combinations where the Boolean function equals 1.
Take the function F(A,B,C) = Σm(1,2,3,5,7). Grouping its 1s gives the simplified SOP expression:
C + A'B
POS (Product of Sums) works from the combinations where the function equals 0.
Grouping the 0s of the same function gives the POS expression:
(B + C)(A' + C)
These two expressions look different but describe the same Boolean function: they give the same output for all eight input combinations. Which form is more useful depends on the problem and the circuit you want to build. Our guide to SOP vs POS in Karnaugh Maps works through this function step by step.
Understanding K-Map Groups
Karnaugh map simplification works by grouping adjacent cells in powers of two:
1, 2, 4, 8, 16
Larger valid groups usually remove more changing variables from the expression.
K-Maps also wrap around their edges. A cell on the left side can be adjacent to one on the right side, and the top and bottom edges work the same way. Because of this, corner cells can sometimes form a valid group.
Groups may also overlap. That is not necessarily an error. In some functions, overlapping groups are needed to cover the required cells with fewer terms or literals.
The highlighted groups in the solver make it easier to compare the visual K-Map with the final Boolean expression. For a detailed breakdown of pairs, quads, octets, overlap, and wrap-around rules, see our complete guide to Karnaugh Map grouping rules.
Don't-Care Conditions
A don't-care condition is shown as X.
It means the output for that input combination does not have to be fixed as 0 or 1.
A don't-care may be included when it helps form a larger K-Map group and create a simpler expression. If it does not help, it can be ignored.
For example, three neighbouring 1 cells cannot form a valid group of three. If a nearby X allows them to form a group of four, the don't-care can be used.
The important point is that X is optional. It is not a required 1 or a required 0.
Because an X leaves that output unspecified, use it only for input combinations that cannot occur or whose output does not matter. If an input must produce a defined output, enter 0 or 1 instead. Our guide to don't-care conditions in Karnaugh Maps includes a worked example with BCD digits.
Boolean Simplification with Quine-McCluskey
A Karnaugh map is a visual way to simplify logic, but finding the best grouping by hand becomes harder as the function grows.
This solver uses the Quine-McCluskey algorithm to perform Boolean simplification systematically.
Quine-McCluskey compares compatible terms and combines terms that differ in only one relevant bit. The process continues until the function's prime implicants have been identified.
A prime implicant is a valid implicant that cannot be expanded further. On a K-Map, these are the largest valid groups that cannot grow.
Some prime implicants are essential prime implicants. These cover a required minterm that no other prime implicant covers, so every minimal answer must include them. A prime implicant that is not essential may still be left out of the final answer if the others already cover its cells. See prime implicants and essential prime implicants for how to find them and how a prime implicant chart shows which ones are mandatory.
This gives the solver a structured way to find the important terms in a Boolean function instead of depending only on a visual guess. Our comparison of Karnaugh Maps and Quine-McCluskey shows when each method is easier to use.
What Petrick's Method Does
Sometimes the essential prime implicants do not cover every required minterm.
When that happens, there may be several possible combinations of remaining prime implicants.
Petrick's Method is used to analyze these remaining covers and determine which combinations can complete the minimized result.
This is especially useful for Boolean functions where several K-Map groupings appear possible and the smallest expression is not obvious from the map alone.
Some functions have more than one equally small cover. The solver ranks covers by the fewest terms first and then the fewest literals, and it shows the one it selects. Another cover with the same counts would be equally correct.
Together, Quine-McCluskey and Petrick's Method provide a systematic approach to SOP and POS minimization.
Reading the Step-by-Step Trace
Below the result, the Step-by-step trace can be opened to see how the solver reached its answer. It follows the stages of the algorithm: reading the map, finding prime implicants with Quine-McCluskey, choosing the cover, and the final result.
The trace lists the minterms, maxterms and don't-cares it read. It reports how many merges each combination pass made and which terms could not merge further, then names the prime implicants as P0, P1 and so on, with the minterms each one covers. It summarises the prime implicant chart by its number of columns and rows, says which prime implicants are essential, and, when the essential ones are not enough, shows the Petrick expression and how many irredundant covers it found. It ends with the cover it selected and the final expression with its term and literal counts.
The trace is written as text. It does not draw the Quine-McCluskey tables or the prime implicant chart as grids, and it shows only the selected cover, even when another cover is equally small. To see those tables worked out by hand, our Quine-McCluskey guide walks through a function with two equally small covers.
2 to 5 Variable K-Maps
The solver supports 2 variable K-Map, 3 variable K-Map, 4 variable K-Map, and 5 variable K-Map problems.
A 2-variable K-Map has 4 cells and is useful for learning basic grouping.
A 3-variable K-Map has 8 cells and makes edge wrapping easier to see. The 2-variable and 3-variable Karnaugh Map guide has worked examples of both layouts.
A 4-variable K-Map has 16 cells and is common in digital logic exercises. At this size, a function may contain several possible groups and overlapping implicants. The 4-variable Karnaugh Map guide explains the 4×4 layout and how its cells are numbered.
A 5-variable K-Map represents 32 input combinations. Manual grouping can become much harder here, especially when the function contains several prime implicants or don't-care conditions. It is usually drawn as two linked 4×4 maps, which the 5-variable Karnaugh Map guide describes.
The solver keeps the K-Map, truth table, Boolean expression, minterms, maxterms, and minimized result connected to the same function.
Minterms, Maxterms, and Truth Tables
A Boolean function can be described in several equivalent ways.
A minterm represents an input combination where the function output is 1.
For example:
F(A,B,C) = Σm(1,3,5,7)
means the output is 1 for minterms 1, 3, 5, and 7.
A maxterm represents an input combination where the function output is 0.
For example:
F(A,B,C) = ΠM(0,2,4,6)
identifies the zero-output rows.
A truth table lists every possible input combination and its output. The K-Map rearranges the same combinations in Gray code order so that adjacent values can be grouped.
If your problem starts with a truth table, you can enter the values directly instead of converting every row manually. For a step-by-step walkthrough, see our tutorial on how to convert a truth table to a Karnaugh Map.
Boolean Expression to K-Map
You can also start with a Boolean expression.
The expression is evaluated for the selected variables, and the corresponding outputs are used to build the truth table and Karnaugh map.
This lets you compare several views of the same function:
- Boolean expression
- truth table
- minterms
- maxterms
- K-Map
- minimized SOP or POS result
Seeing these forms together can make it easier to check whether a simplification is correct.
Logic Circuit and Gate Count
A minimized Boolean expression is often used to build a logic circuit.
The solver can generate a gate-level circuit diagram based on the simplified expression so you can see how the result maps to logic gates.
It also shows information such as the number of terms, literals, and gates.
For example:
A'BC
contains one term and three literals.
Reducing unnecessary terms and literals can make a Boolean expression easier to read and can also produce a simpler logic implementation.
Step-by-Step PDF Export
The solution can be exported as a PDF for later review.
The PDF is a text summary. It contains your input (variable count, output form, minterms, maxterms, and don't-cares), the simplified expression, the term, literal, and gate counts, and the full step-by-step explanation. The Karnaugh map, highlighted groups, and circuit diagram are shown in the solver on the page and are not drawn in the PDF.
This is useful when you want to keep a solved example, review your work later, or compare the result with a hand-worked K-Map.
SOP vs POS: Which Should You Use?
Use SOP when you want to simplify the conditions where the function output is 1.
Use POS when you want to simplify the conditions where the function output is 0.
Neither form is always shorter.
Some Boolean functions have a smaller SOP expression, while others have a simpler POS form. The example earlier on this page favours SOP: C + A'B has 2 terms and 3 literals, against 2 factors and 4 literals for the POS form. The function F(A,B,C,D) = (A + B)(C + D) goes the other way. Its POS form has 2 factors and 4 literals, while its minimal SOP, AC + AD + BC + BD, needs 4 terms and 8 literals. These counts compare the written expressions, not the cost of building them.
If your problem does not require one specific format, comparing both can help you choose the cleaner representation.
