radixflip

Truth Table & K-Map Solver

Type a boolean expression and get its truth table, Karnaugh map and minimized sum-of-products form, live.

Solve an Expression

Operators: NOT (!, ~, A'), AND (&, *, AB), OR (|, +), XOR (^), NAND, NOR, XNOR, parentheses. Variables are single letters A to Z, up to 6 for the truth table, up to 4 for the K-map.

Truth Table

K-Map

Logic gates →  ·  Bitwise calculator →

How to solve a truth table and K-map

  1. Type the expression. Use variables A to D and any of AND, OR, NOT, XOR, NAND, NOR, XNOR.
  2. Read the truth table. Every input combination appears with its output, and the minterms are listed.
  3. Read the K-map. Groups of 1s in the grid show which terms merge.
  4. Read the minimized form. The sum-of-products form is the shortest equivalent expression.

Worked example: majority of A, B, C

The expression AB + BC + AC is 1 when at least two inputs are 1. Its truth table has 1s on rows 3, 5, 6 and 7:

ABCOutput
0111
1011
1101
1111

On the K-map these four 1s form three pairs, giving the three terms BC, AC and AB. No term can be dropped, so the expression is already minimal.

Frequently asked questions

What is a truth table?

A truth table lists every possible combination of inputs for a boolean expression, with the output for each row. With 2 variables there are 4 rows, with 3 there are 8, and with 4 there are 16. Each row where the output is 1 is called a minterm. Type an expression above and the full table appears live.

What is a K-map?

A Karnaugh map (K-map) lays the truth table out as a grid so that cells next to each other differ in only one variable. Groups of 1s that sit together in powers of two (1, 2, 4, 8 cells) can be merged, and each merged group drops the variable that changes inside it. That is how the minimized sum-of-products form is found. This solver draws K-maps for 2, 3 and 4 variables.

Which operators can I type?

NOT (!, ~, or a trailing apostrophe, as in A'), AND (&, *, or just writing letters together, as in AB), OR (|, +), XOR (^), NAND, NOR and XNOR, plus parentheses. You can also type the words AND, OR, XOR, NAND, NOR, XNOR and NOT. NOT binds tightest, then AND, then XOR, then OR. Example: AB + BC + AC.

Why is AB + BC + AC the default example?

It is the majority function: the output is 1 when at least two of A, B, C are 1. Its minterms are 3, 5, 6 and 7, and it is already minimal, so the K-map shows three groups of two cells each. Try AB + A'C + BC to see a redundant term disappear: BC is covered by the other two, so the minimized form is AB + A'C.

What does a minimized sum-of-products form mean?

It is the shortest OR of AND terms that gives the same output on every row. Each term is one group from the K-map. Fewer terms and fewer literals per term mean fewer logic gates when the circuit is built. The solver checks its answer by construction: the groups come from the minterms themselves, so the minimized form matches the original on all rows.

Why do 5 and 6 variables get no K-map?

A K-map for 5 variables needs two 4-variable maps, and 6 variables need four, which is hard to read and easy to mis-group. For 5 or 6 variables the solver still shows the full truth table and the canonical sum of minterms, which is always correct, just not minimized.

Logic gates →  ·  Bitwise calculator →