Skip to content
digiwleea Tools
The theory Open the lab →

Truth table to Boolean expression converter

To turn a truth table into a Boolean expression, write one AND term for every row where the output is 1 and OR the terms together: that is the sum of products. Click or type the output column below to get the minterms and maxterms, the canonical and minimal sum of products and product of sums, and a working circuit for the result.

How the conversion works

Every row of a truth table has two terms that single it out. Its minterm is the AND of all the variables, each inverted where the row has a 0, so it is 1 on that row only. Its maxterm is the OR of all the variables, each inverted where the row has a 1, so it is 0 on that row only. Here is the three-input majority function, which is 1 when at least two inputs are 1:

RowA B CFTerm used
00000M0 = (A + B + C)
10010M1 = (A + B + C')
20100M2 = (A + B' + C)
30111m3 = A'BC
41000M4 = (A' + B + C)
51011m5 = AB'C
61101m6 = ABC'
71111m7 = ABC

ORing the minterms of the 1 rows gives the canonical sum of products, F = Σm(3, 5, 6, 7) = A'BC + AB'C + ABC' + ABC. ANDing the maxterms of the 0 rows gives the canonical product of sums, F = ΠM(0, 1, 2, 4) = (A + B + C)(A + B + C')(A + B' + C)(A' + B + C). Both are exact but long. Minimizing them, as a Karnaugh map or the Quine-McCluskey method does, gives AB + AC + BC and (A + B)(A + C)(B + C): 6 literals each instead of 12. The minimal sum of products is the carry out of a full adder.

SOP or POS: which is smaller?

It depends on the table, so the converter shows both. These counts come from the converter itself:

FunctionMinimal SOPMinimal POS
Majority of 3AB + AC + BC, 6 literals(A + B)(A + C)(B + C), 6 literals
Prime number detector, 0 to 154 terms, 12 literals4 terms, 9 literals
XOR of 3 (full adder sum)4 terms, 12 literals4 terms, 12 literals
BCD digit 5 or moreA + BC + BD, 5 literals(A + B)(A + C + D), 5 literals

XOR-style functions such as parity do not simplify at all in two levels; they are much smaller built from XOR gates. Type an expression into the logic circuit generator to compare a circuit drawn as written with its minimal SOP.

Don't cares

Mark a row X when its output does not matter, usually because that input can never occur. A BCD digit only uses the codes 0 to 9, so in the "BCD digit 5 or more" example rows 10 to 15 are don't cares. The minimizer is free to read each X as a 0 or a 1, and that is what shrinks the answer to A + BC + BD. The canonical forms list only the true 1 and 0 rows, and the drawn circuit is checked on the care rows. For a grouping you can see, try the same table in the Karnaugh map solver.

From expression to circuit

A minimal SOP becomes an AND-OR circuit: one AND gate per term, one OR gate to combine them, and a shared inverter for each complemented variable. A POS becomes the mirror image, OR gates feeding an AND. The circuit above is drawn from real digiwleea gates and checked by the simulator before it appears; open it in the lab to extend it. The truth table to circuit lesson walks through the recipe, and canonical forms covers the notation.

Frequently asked

How do you convert a truth table to a Boolean expression?

Write one product term for every row whose output is 1, using each variable plain where it is 1 in that row and inverted where it is 0, then OR the terms together. That is the canonical sum of products. Simplify it with Boolean algebra, a Karnaugh map or the Quine-McCluskey method to get the minimal form.

What is the difference between SOP and POS?

A sum of products (SOP) ORs together AND terms and is built from the rows where the output is 1; it becomes an AND-OR circuit. A product of sums (POS) ANDs together OR terms and is built from the rows where the output is 0; it becomes an OR-AND circuit. Both describe the same function, and either can be smaller: the prime number detector on this page needs 12 literals as an SOP and 9 as a POS.

What is a minterm?

A minterm is a product term that contains every variable once, plain or inverted, and is 1 on exactly one row of the truth table. Minterm m3 of three variables is A'BC, because row 3 is A = 0, B = 1, C = 1. A function is the sum of the minterms of its 1 rows, written F = Σm(...).

What is a maxterm?

A maxterm is a sum term that contains every variable once and is 0 on exactly one row. It inverts the variables that are 1 in that row: maxterm M3 of three variables is (A + B' + C'). A function is the product of the maxterms of its 0 rows, written F = ΠM(...).

What does X mean in a truth table?

X marks a don't care: a row whose output does not matter, usually because that input combination can never happen, like the codes 10 to 15 in a BCD digit. The minimizer may treat each X as 0 or 1, whichever makes the expression smaller, and the circuit is only checked on the rows that matter.

Is the minimal expression unique?

Not always. Some functions have several different covers with the same number of terms and literals, and any of them is a correct minimal answer. This converter shows one of them. The canonical forms, on the other hand, are unique for a given table.

How many variables can it handle?

Up to 6 variables, which is 64 rows. Every expression is computed for any table of that size; the live circuit is drawn when it needs 24 gates or fewer.

A truth table, an expression and a circuit are three views of one function. Generate a table from an expression with the truth table generator, simplify an expression with the Boolean simplifier, or open the lab and build the circuit yourself.

Related tools: logic circuit generator, Karnaugh map solver and logic gate symbols and truth tables.

Open the lab →