A truth table already tells you everything about a Boolean function — every input combination and the output it produces. A Karnaugh Map doesn't add new information. It rearranges those same outputs into a grid where related combinations sit next to each other, so grouping and simplification become visible instead of algebraic.
This article walks through that conversion directly: taking rows from a truth table and placing them correctly into K-Map cells, then grouping and simplifying the result.
Truth Table and K-Map: What Changes?
A truth table lists input combinations as rows, one after another, usually in plain binary order. A K-Map takes those same combinations and places them into cells arranged in a grid. The outputs themselves don't change at all — a row that outputs 1 in the truth table still outputs 1 once it's placed on the map. What changes is the arrangement, and that arrangement follows Gray code rather than binary counting order.
If you haven't worked through what a Karnaugh Map is and why that rearrangement matters, it's worth a quick read before continuing here.
This article assumes you already understand the basic grid and focuses on the conversion process.
Step 1: Count the Variables
The number of variables in the function determines how many rows the truth table has and how many cells the K-Map needs:
- 2 variables → 4 rows, 4 K-Map cells
- 3 variables → 8 rows, 8 cells
- 4 variables → 16 rows, 16 cells
- 5 variables → 32 combinations
Each variable doubles the number of possible input combinations, since every added variable can independently be 0 or 1. The map size just mirrors that.
Step 2: Identify the Output Column
Once the variable count is settled, look at the output column of the truth table. If you're working toward a Sum-of-Products (SOP) result, the rows that matter are the ones outputting 1. If you're working toward a Product-of-Sums (POS) result, focus on the rows outputting 0 instead.
Some truth tables also include an X in the output column for combinations that are undefined or that can't occur. Those are don't-care values, and they get carried over to the K-Map as X — not automatically treated as a 1.
Step 3: Find the Minterm Numbers
Each row's binary input values correspond directly to a decimal index, called a minterm number. For a 3-variable function with inputs A, B, C, the correspondence looks like this:
- 000 → m0
- 001 → m1
- 010 → m2
- 011 → m3
- 100 → m4
- 101 → m5
- 110 → m6
- 111 → m7
The binary value of ABC, read as a plain binary number, gives you the minterm index.
Rows with a 0 output correspond to the same decimal indices when identifying maxterms for a POS form.
Step 4: Place the Values in Gray Code Order
This is the step that trips people up most often. K-Map rows and columns are not labeled in ordinary binary counting order.
For two-variable axis labels, use:
00, 01, 11, 10
Not:
00, 01, 10, 11
The difference matters because Gray code guarantees that each label differs from its neighbor by exactly one bit.
Going from 01 → 11 changes only the first bit.
Going from 11 → 10 changes only the second bit.
The wrap-around transition 10 → 00 also changes only one bit.
If plain binary order were used instead, the jump 01 → 10 would change both bits at once, and adjacent cells would no longer represent inputs differing in exactly one variable.

Gray-code order keeps neighboring K-Map columns one bit apart; ordinary binary order would break that adjacency.
Step 5: Fill the K-Map
Each truth-table row goes into exactly one cell. Turn the row's input bits into a minterm index, find that index on the map, and copy the row's output into that cell. Nothing is recalculated.
A two-variable function is small enough to do by eye. Take this truth table:
| A | B | m | F |
|---|---|---|---|
| 0 | 0 | m0 | 1 |
| 0 | 1 | m1 | 1 |
| 1 | 0 | m2 | 0 |
| 1 | 1 | m3 | 1 |
That gives F(A, B) = Σm(0, 1, 3). Put A on the rows and B on the columns:
| A \ B | 0 | 1 |
|---|---|---|
| 0 | 1 | 1 |
| 1 | 0 | 1 |
The top row holds m0 and m1, the bottom row holds m2 and m3, and every cell carries the output of the row with the same number. Only the visual position changed.
With one variable per axis, 0, 1 is already Gray-code order. The order starts to matter when an axis carries two variables, as it does on 3- and 4-variable maps, such as the 16-row example later in this article.
Step 6: Group Adjacent 1s
With the map filled in, look for the largest valid groups of 1s following standard Karnaugh Map grouping rules. Every 1 must end up in at least one group.
On the two-variable map, the top row m0, m1 is a pair, and so is the right-hand column m1, m3. The two pairs overlap at m1. That overlap is valid and useful.
Always prefer the largest valid group. Each time a group doubles in size, one more variable drops out of its term.
Step 7: Write the Simplified Boolean Expression
Inside a group, variables that stay constant survive in the simplified term. Variables that change disappear. A variable that stays 1 is written as itself, and one that stays 0 is written complemented.
- For
m0, m1: A stays 0 and B changes, so the term isA'. - For
m1, m3: B stays 1 and A changes, so the term isB.
Combining both groups gives:
F = A' + B
The two overlapping pairs cover every required 1. The only input left out is A = 1, B = 0, which is the single 0 in the truth table.
What About POS?
The same truth-table-to-K-Map process works for Product-of-Sums, but the grouping starts from the 0 cells instead of the 1 cells.
Locate the truth-table rows whose output is 0, identify their maxterm indices, place those zeros in the same Gray-code map, and form the largest valid groups.
Each zero-group produces a sum term, and the resulting terms are multiplied together to produce POS. The comparator example later in this article is worked through in both forms (see our full guide on SOP vs POS in Karnaugh Maps).
How to Handle Don't-Care Values
If a truth-table row contains X, carry that X into the corresponding K-Map cell.
Do not decide that it must be 0 or 1 before placing it.
For SOP, an X can be treated like a 1 if doing so allows a larger useful group. Otherwise, leave it unused.
For POS, an X may similarly help extend a zero-group.
A don't-care is optional. Use it only when it improves the simplification; learn more in our detailed tutorial on don't-care conditions in Karnaugh Maps.
4-Variable Truth Table to K-Map
The process scales directly to four variables, as explored in our dedicated 4-variable Karnaugh Map guide.
A 4-variable truth table contains 16 rows and the K-Map contains 16 cells.
A common layout divides the variables across two axes and uses Gray-code order on both:
00, 01, 11, 10
For example, AB can label one axis and CD the other.
The workflow remains the same:
find the row/index → place the output → form valid groups → simplify.
The larger map simply creates more opportunities for wrap-around and overlapping groups. The rest of this section follows one complete 4-variable function from its truth table to its simplified expressions.
Example: A Two-Bit Comparator
A two-bit unsigned comparator takes two numbers, each written with two bits, and outputs 1 when the first number is greater than the second. Call the numbers P and Q. P is written with the bits A (the more significant) and B, and Q with the bits C (the more significant) and D:
P = 2A + B, Q = 2C + D
The output is F = 1 when P > Q, and F = 0 otherwise.
The function has four Boolean inputs, A, B, C and D, because each bit is its own variable. P and Q are not variables. They are only the numbers that the bits spell out, each between 0 and 3.
The Comparator's Truth Table
Four inputs give 2⁴ = 16 combinations. List them in ordinary binary order, from ABCD = 0000 to 1111. For each row, work out P and Q and write 1 if P > Q, otherwise 0.
| m | A | B | C | D | P | Q | F |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
| 2 | 0 | 0 | 1 | 0 | 0 | 2 | 0 |
| 3 | 0 | 0 | 1 | 1 | 0 | 3 | 0 |
| 4 | 0 | 1 | 0 | 0 | 1 | 0 | 1 |
| 5 | 0 | 1 | 0 | 1 | 1 | 1 | 0 |
| 6 | 0 | 1 | 1 | 0 | 1 | 2 | 0 |
| 7 | 0 | 1 | 1 | 1 | 1 | 3 | 0 |
| 8 | 1 | 0 | 0 | 0 | 2 | 0 | 1 |
| 9 | 1 | 0 | 0 | 1 | 2 | 1 | 1 |
| 10 | 1 | 0 | 1 | 0 | 2 | 2 | 0 |
| 11 | 1 | 0 | 1 | 1 | 2 | 3 | 0 |
| 12 | 1 | 1 | 0 | 0 | 3 | 0 | 1 |
| 13 | 1 | 1 | 0 | 1 | 3 | 1 | 1 |
| 14 | 1 | 1 | 1 | 0 | 3 | 2 | 1 |
| 15 | 1 | 1 | 1 | 1 | 3 | 3 | 0 |
Read each row's ABCD bits as one binary number to get its minterm index: 0100 is 4 and 1101 is 13. Row 4 has P = 1 and Q = 0, so F = 1. Row 5 has P = 1 and Q = 1, which are equal, so F = 0. Row 14 has P = 3 and Q = 2, so F = 1.
Six rows output 1:
F(A, B, C, D) = Σm(4, 8, 9, 12, 13, 14)
The other ten rows output 0, including the four rows where P equals Q (m0, m5, m10 and m15).
Placing the Comparator on the K-Map
Use a 4×4 map with AB on the rows and CD on the columns, both in Gray-code order 00, 01, 11, 10. First, the minterm number that sits in each cell:
| AB \ CD | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | m0 | m1 | m3 | m2 |
| 01 | m4 | m5 | m7 | m6 |
| 11 | m12 | m13 | m15 | m14 |
| 10 | m8 | m9 | m11 | m10 |
Now the same map with the comparator's outputs copied in:
| AB \ CD | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | 0 | 0 | 0 | 0 |
| 01 | 1 | 0 | 0 | 0 |
| 11 | 1 | 1 | 0 | 1 |
| 10 | 1 | 1 | 0 | 0 |
The minterm numbers do not run in counting order across the map. The index comes from binary counting, because ABCD is read as a number, while the position comes from Gray code. m3 (0011) sits in the third column because CD = 11 is the third column label, and m12 (1100) sits in the third row because AB = 11 is the third row label. The top row reads m0, m1, m3, m2, not m0, m1, m2, m3.
Grouping the Comparator's 1s
The 1s are m4, m8, m9, m12, m13 and m14. Three groups cover them.
- Quad
m8, m9, m12, m13: the 2×2 block in the bottom-left corner. AB = 10 and AB = 11 are neighbouring rows, and CD = 00 and CD = 01 are neighbouring columns. A stays 1 and C stays 0, while B and D change. The term isAC'. - Pair
m4, m12: the first column (CD = 00), across the second and third rows (AB = 01 and 11). B stays 1, C stays 0 and D stays 0, while A changes. The term isBC'D'. - Pair
m12, m14: the row AB = 11, in the first and last columns (CD = 00 and 10). These columns are adjacent because the map wraps around. A stays 1, B stays 1 and D stays 0, while C changes. The term isABD'.
The cell m12 belongs to all three groups, and that overlap is valid. No group can be enlarged without including a 0, and each one is essential: m4 appears only in BC'D', m14 only in ABD', and m8 and m9 only in AC'.
Adding the three terms gives:
F = AC' + BC'D' + ABD'
That is three terms and eight literals.
Each term has a plain meaning in terms of the numbers. AC' says that P is at least 2 while Q is at most 1. BC'D' says that Q is 0 while P is odd, so P is 1 or 3. ABD' says that P is 3 while Q is 0 or 2.
Checking the Comparator Result
Test the expression against the truth table. For m6 (0110), A = 0 makes AC' and ABD' zero, and C = 1 makes BC'D' zero, so F = 0, which matches P = 1 and Q = 2. For m14 (1110), ABD' = 1 · 1 · 1 = 1, so F = 1, which matches P = 3 and Q = 2. For m15 (1111), D = 1 and C = 1 make all three terms zero, so F = 0, which matches P = Q = 3.
The same check works for all 16 rows. This function has no don't-care rows, so every row must match.
The Comparator in POS Form
For POS, group the 0s instead. The ten zeros are m0, m1, m2, m3, m5, m6, m7, m10, m11 and m15, and five quads cover them. In a zero-group, a variable that stays 0 appears as itself and one that stays 1 appears complemented, the opposite of SOP.
m0, m1, m2, m3: A and B stay 0, giving(A + B).m1, m3, m5, m7: A stays 0 and D stays 1, giving(A + D').m2, m3, m6, m7: A stays 0 and C stays 1, giving(A + C').m2, m3, m10, m11: B stays 0 and C stays 1, giving(B + C'). This group wraps around from the first row to the last.m3, m7, m11, m15: C and D stay 1, giving(C' + D').
Multiplying the factors gives:
F = (A + B)(A + D')(A + C')(B + C')(C' + D')
This is five factors and ten literals. It describes exactly the same function as the SOP form, so it gives the same output for all 16 inputs. For this comparator the SOP form is shorter, with three terms and eight literals. Which form suits you depends on the circuit you want to build.
Reproducing the Comparator in the Solver
In the Karnaugh Map Solver, choose 4 variables, select the Minterms input, enter 4, 8, 9, 12, 13, 14 and press Apply. The SOP result should read AC' + BC'D' + ABD'. Switching to POS should give (A + B)(A + D')(A + C')(B + C')(C' + D').
You can also use the Truth Table input instead: set the output of rows m4, m8, m9, m12, m13 and m14 to 1 and leave the rest at 0. The map the solver draws should match the second table above.
Common Conversion Mistakes
- Laying out the K-Map in ordinary binary order instead of Gray code.
- Placing an output in the wrong cell after confusing the minterm index with its visual position.
- Treating a multi-bit number as a single variable. In the comparator, every bit of P and Q is its own Boolean variable with its own truth-table column and its own place on the map axes.
- Treating diagonal cells as adjacent.
- Forgetting that opposite edges can be adjacent.
- Creating groups of 3, 6, or another non-power-of-two size.
- Forcing a don't-care X into a group where it gives no benefit.
- Mixing SOP and POS grouping rules.
- Stopping at a smaller group when a larger valid group is available.
A Quick Truth Table to K-Map Checklist
- Count the variables.
- Read the output column.
- Identify the minterm or maxterm indices.
- Set up the K-Map in Gray-code order.
- Place each 0, 1, or X in the correct cell.
- Form the largest useful valid groups.
- Find the simplified term from each group.
- Combine the terms.
- Verify the result against the original truth table.
Checking Your Result
Once you have the simplified expression, confirm that it produces the same output as the original truth table for every input that is not a don't-care.
Try several rows manually, or compare the full set of outputs.
If you want to compare your manual conversion with an automated result, the Karnaugh Map Solver can build the K-Map from the same truth-table values and show its grouping.
Frequently Asked Questions
How do I convert a truth table to a Karnaugh Map?
Count the variables, identify each row's minterm index, and place the output in the matching K-Map cell using Gray-code ordering. The outputs stay the same; only their positions change.
How do I know which K-Map cell matches a truth-table row?
Read the row's input bits as a binary number to get its decimal minterm index, then find that minterm's position in the Gray-code map.
Why does a K-Map use Gray code?
Gray code makes neighboring cells differ by only one bit. That single-variable difference is what allows adjacent cells to be grouped and simplified.
Do I put zeros in a K-Map?
Yes. Every truth-table output belongs in the K-Map. For SOP you usually group the 1s, while for POS you group the 0s.
What does X mean in a truth table or K-Map?
X is a don't-care condition. It can be used as either value when that helps create a better group, or ignored when it provides no simplification benefit.
Can K-Map groups overlap?
Yes. A cell can belong to multiple valid groups when the overlap helps produce a simpler Boolean expression.

