K-MAP Boolean Minimization

Karnaugh Map Calculator

Solve 2-variable, 3-variable and 4-variable Karnaugh maps online. Enter minterms and optional don’t-care conditions, generate the Gray-code K-map and calculate an equivalent minimized Sum of Products Boolean expression.

✓ 2 Variable K-Map ✓ 3 Variable K-Map ✓ 4 Variable K-Map ✓ Minterms ✓ Don’t-Cares ✓ Minimal SOP
K
Karnaugh Map Solver
● Ready
Enter minterm indices separated by commas or spaces. For 3 variables the valid range is 0–7.
Enter optional don’t-care indices. They must not overlap the minterms.
K-Map Options
K-map rule: Adjacent cells differ in only one variable because rows and columns use Gray-code ordering. Valid groups contain powers of two: 1, 2, 4, 8 or 16 cells. Opposite edges are adjacent, so K-map groups may wrap around the map.
Karnaugh Map Result Minimized
Minimized SOP Expression
Variables
K-Map Cells
Minterms
Don’t-Cares
Prime Implicants
Selected Groups
Literals
Classification
Generated Karnaugh Map Gray-code ordering
Selected K-Map Groups
Minterm Analysis

Karnaugh Map Calculator

The Karnaugh Map Calculator, also called a K-map solver, simplifies Boolean functions using the same adjacency principle used in manual Karnaugh map minimization. Enter the minterms where the output is 1 and optional don’t-care conditions, and the calculator generates the map and finds an equivalent minimized SOP expression.

This tool supports two, three and four Boolean variables. Those sizes correspond to K-maps containing 4, 8 and 16 cells respectively. Each cell represents one truth-table input combination.

The generated map uses Gray-code ordering rather than ordinary binary numeric order. That arrangement ensures horizontally and vertically adjacent cells differ in exactly one Boolean variable.

How to Use the Karnaugh Map Calculator

Select the number of Boolean variables and enter the minterm indices where the function equals 1. You may also provide don’t-care terms that the simplifier is free to treat as either 0 or 1 when doing so creates a larger useful group.

3 variables: A, B, C Minterms: 1, 3, 5, 7 Binary rows: 1 = 001 3 = 011 5 = 101 7 = 111 All four rows have: C = 1 Simplified: C

What Is a Karnaugh Map?

A Karnaugh map is a visual method for simplifying Boolean functions. Truth-table outputs are arranged in a grid so neighboring cells differ in only one input variable.

Groups of adjacent 1 cells can then eliminate variables whose values change inside the group. Larger groups eliminate more variables and usually produce simpler Boolean expressions.

2-Variable Karnaugh Map

A two-variable K-map has four cells because two Boolean variables create 2² = 4 possible combinations.

Variables: A, B Minterms: 0, 1 Binary: 00 01 A remains 0 B changes Simplified: NOT A

3-Variable Karnaugh Map

A three-variable K-map contains eight cells. One variable is commonly placed on the row axis while the remaining two use Gray-code ordering on the columns.

Column order for BC: 00 01 11 10 Notice: 00 → 01 changes one bit 01 → 11 changes one bit 11 → 10 changes one bit 10 → 00 also changes one bit through wrap-around

4-Variable Karnaugh Map

A four-variable K-map contains sixteen cells, generally arranged as a 4×4 grid. Both axes use two-bit Gray-code order.

Rows AB: 00, 01, 11, 10 Columns CD: 00, 01, 11, 10 Total cells: 4 × 4 = 16

The left and right edges are adjacent, and the top and bottom edges are also adjacent.

Karnaugh Map Gray Code Ordering

K-map cells are not arranged in ordinary numeric binary order. Gray code is used so every pair of neighboring cells differs by exactly one bit.

Position Gray Code Decimal
1000
2011
3113
4102

K-Map Group Sizes

Every valid Karnaugh map group contains a power-of-two number of cells. A group may contain one, two, four, eight or sixteen cells depending on the map size.

Valid group sizes: 1 2 4 8 16 Invalid group sizes: 3 5 6 7 10

A larger group generally produces fewer literals because more variables change inside the group and can therefore be eliminated.

Why K-Map Groups Should Be as Large as Possible

A group containing two cells eliminates one changing variable. A group of four eliminates two variables, and a group of eight can eliminate three variables.

4-variable minterm: A AND B AND C AND D = 4 literals Group of 2: can reduce to 3 literals Group of 4: can reduce to 2 literals Group of 8: can reduce to 1 literal

Overlapping Karnaugh Map Groups

K-map groups are allowed to overlap. A minterm may participate in more than one group if the overlap helps create larger implicants or is required to cover another minterm efficiently.

The important requirement is that every required 1 cell must be covered by at least one selected implicant.

K-Map Edge Wrapping

The opposite edges of a Karnaugh map are logically adjacent. This includes the left and right edges as well as the top and bottom edges. The four corner cells of a four-variable map can therefore form a valid four-cell group.

4×4 K-map corners: top-left top-right bottom-left bottom-right These four cells are mutually connected through horizontal and vertical wrap-around.

Using Don’t-Cares in a Karnaugh Map

A don’t-care condition represents an input combination whose output is irrelevant or cannot occur. It is commonly written as X.

During minimization, a don’t-care may be included in a group when doing so produces a simpler expression. It does not need to be covered.

Minterms: 1, 3, 7 Don't-care: 5 Cells 1, 3, 5, 7 can form a four-cell group. Simplified: C

Minterm Numbering

A minterm index corresponds to the binary value formed by the Boolean variables in their defined order.

Variables: A B C A B C = 0 0 0 Binary 000 Minterm 0 A B C = 1 0 1 Binary 101 Minterm 5 A B C = 1 1 1 Binary 111 Minterm 7

Karnaugh Map to Boolean Expression

Each selected group becomes a product term in a minimized Sum of Products expression. A variable remains in the product only when its value is constant throughout the entire group.

Group cells: m4 = 100 m5 = 101 Variables: A = 1 in both cells B = 0 in both cells C changes Product term: A AND NOT B

Prime Implicants in a K-Map

A prime implicant represents a group that cannot be expanded into a larger valid group without including a required zero cell.

An essential prime implicant covers at least one minterm that no other prime implicant can cover. Essential prime implicants must appear in every minimum cover of the function.

Sum of Products from a K-Map

The calculator generates a minimized SOP form. Each selected implicant becomes an AND product, and those product terms are combined with OR.

Selected groups produce: A AND NOT B NOT A AND C Final SOP: (A AND NOT B) OR (NOT A AND C)

K-Map Example: Simplifying to One Variable

3 variables: A, B, C Σm(1,3,5,7) Binary: 001 011 101 111 C is 1 in every minterm. A changes. B changes. Simplified: C

K-Map Example with Four Variables

Variables: A, B, C, D Minterms: 0, 1, 2, 3 Binary: 0000 0001 0010 0011 A = 0 throughout B = 0 throughout C changes D changes Simplified: NOT A AND NOT B

K-Map for a Tautology

If every cell in the map is 1, the Boolean function is always true and the entire map forms one group.

3 variables: Σm(0,1,2,3,4,5,6,7) All 8 cells = 1 Simplified: TRUE

K-Map for a Contradiction

If there are no minterms, the function is false for every input combination.

Minterms: none All required cells: 0 Simplified: FALSE

Karnaugh Map vs Truth Table

Method Main Purpose Arrangement
Truth Table Show every input/output combination Binary counting order
Karnaugh Map Visually simplify Boolean functions Gray-code adjacency

A K-map contains the same logical information as the function’s truth table but rearranges the rows so adjacent values can be combined.

Karnaugh Map vs Boolean Expression Simplifier

A Boolean expression simplifier starts from an expression, while a K-map calculator commonly starts from minterm or maxterm indices.

Both approaches may ultimately produce the same minimized function. The K-map is especially useful when the Boolean function is already available as a truth table or list of minterms.

Common Karnaugh Map Mistakes

A common mistake is arranging columns in ordinary binary order such as 00, 01, 10, 11. Karnaugh maps require Gray-code order 00, 01, 11, 10.

Another mistake is creating groups containing three or six cells. Every group must contain a power-of-two number of cells.

Users also frequently forget that opposite edges are adjacent. Ignoring wrap-around groups can produce an unnecessarily complicated expression.

Don’t-care cells should not be forced into groups. They should be used only when they help form a larger useful implicant.

Karnaugh Map Calculator Limitations and Notes

This calculator supports standard 2-variable, 3-variable and 4-variable Karnaugh maps. These are the map sizes most commonly solved manually.

The calculator minimizes the function into a two-level SOP expression. If multiple minimum covers exist with the same number of product terms and literals, the tool returns one valid minimum cover.

Don’t-care values are allowed to participate in simplification but are never treated as mandatory output-1 minterms.

Karnaugh Map Calculator FAQs

What is a Karnaugh map calculator?
It arranges Boolean minterms in Gray-code order and finds groups that produce a simpler equivalent logic expression.
How many cells are in a 2-variable K-map?
A 2-variable Karnaugh map contains 4 cells.
How many cells are in a 3-variable K-map?
A 3-variable K-map contains 8 cells.
How many cells are in a 4-variable K-map?
A 4-variable K-map contains 16 cells.
Why does a K-map use Gray code?
Gray code ensures adjacent cells differ by only one Boolean variable, which allows that changing variable to be eliminated when cells are grouped.
What group sizes are valid?
Valid groups contain powers of two: 1, 2, 4, 8 or 16 cells depending on the map size.
Can Karnaugh map groups overlap?
Yes. Overlap is valid and can be useful when it helps form larger groups or cover required minterms efficiently.
Can K-map groups wrap around the edges?
Yes. Opposite horizontal and vertical edges are adjacent in a Karnaugh map.
What is a don’t-care condition?
A don’t-care is an input combination whose output does not matter. It can be treated as 0 or 1 when doing so simplifies the Boolean function.
Do don’t-cares need to be included in groups?
No. They are included only when they help create larger or simpler groups.
What is a prime implicant?
A prime implicant is a valid group that cannot be expanded further without including a required zero.
What is an essential prime implicant?
It is a prime implicant that covers at least one required minterm not covered by any other prime implicant.
What does Σm mean?
Σm lists the minterm indices where the Boolean function equals 1.
Can an empty minterm list be used?
Yes. An empty minterm list represents a function that is always FALSE.
What if every K-map cell is 1?
The entire map can be grouped and the function simplifies to TRUE.
Scroll to Top