Boolean Algebra Calculator: Truth Tables, De Morgan's Laws, and Logic Simplification
Every "if" statement you write, every database query you filter, and every search engine result you see is powered by Boolean logic — a mathematical system where every variable is strictly true or false (1 or 0). George Boole published this algebra in 1854 in "The Laws of Thought," and it sat quietly in mathematics departments for nearly a century before Claude Shannon realised it could describe electrical switching circuits, laying the foundation for every digital computer ever built. Today, Boolean algebra underpins everything from SQL WHERE clauses to search engine queries to the design of microprocessors with billions of logic gates. Our free Boolean algebra calculator lets you enter any Boolean expression (up to 8 variables), instantly see its truth table, simplify it using algebraic rules and De Morgan's laws, and view the equivalent logic gate diagram — all running in your browser.
Boolean Logic Calculator
Free · No registration
Step-by-Step Guide
Enter Your Boolean Expression
Type your expression using standard notation: & or ∧ for AND, | or ∨ for OR, ! or ¬ for NOT, ^ or ⊕ for XOR. You can use parentheses for grouping, and variable names like A, B, C, up to H. Example: (A & B) | (!A & C) represents "either A and B are both true, or A is false and C is true." The calculator validates syntax in real time and shows you an auto-formatted version of your expression with proper mathematical symbols.
View the Truth Table
The truth table displays every possible combination of input values (2ⁿ rows for n variables) and the resulting output. Each row shows whether the expression evaluates to true or false given that specific input. For 3 variables (A, B, C), you'll see 8 rows; for 4 variables, 16 rows. The truth table is colour-coded — green for true outputs, grey for false — so you can instantly scan for patterns. This is the fastest way to understand what a Boolean expression actually means.
Apply Simplification and See the Circuit
Click "Simplify" and the calculator applies Boolean algebra identities to reduce your expression to its simplest form. The step-by-step panel shows which rule was applied at each stage: idempotent law (A&A=A), complement law (A&!A=0), absorption law (A|(A&B)=A), and De Morgan's laws. The simplified expression is shown alongside a logic gate diagram using standard ANSI/IEEE symbols — AND (flat-back), OR (curved-back), NOT (triangle with bubble), XOR (OR with extra line).
Tips & Best Practices
De Morgan's laws are the two most powerful Boolean identities: !(A & B) = !A | !B, and !(A | B) = !A & !B. They let you convert ANDs to ORs and vice versa while pushing NOT inward. In practical terms: "not (raining AND cold)" equals "not raining OR not cold." These laws are essential for simplifying complex SQL WHERE clauses and search engine queries.
The XOR (exclusive OR) operator returns true when exactly one input is true — it's the "one or the other, but not both" operator. XOR with a constant 1 is the same as NOT: A ⊕ 1 = !A. XOR is also its own inverse: (A ⊕ B) ⊕ B = A. This self-inverse property makes XOR the foundation of many encryption schemes and basic checksum algorithms.
NAND and NOR are called "universal gates" because you can build AND, OR, and NOT using only NAND gates (or only NOR gates). Every digital circuit in existence can theoretically be reduced to a network of NAND gates. In fact, NAND flash memory (used in SSDs and USB drives) gets its name from this very gate.
When writing Boolean conditions in code, the order of conditions matters for short-circuit evaluation. In `if (cheapCheck() && expensiveCheck())`, if cheapCheck() returns false, expensiveCheck() never runs. Put your fastest-failing condition first — it's a simple optimisation that compounds in tight loops.
Truth tables grow exponentially: n variables means 2ⁿ rows. At 8 variables, that's 256 rows — still manageable. At 32 variables, you'd need over 4 billion rows. This is why formal verification of large digital circuits uses SAT solvers and Binary Decision Diagrams rather than brute-force truth tables.
SQL's three-valued logic (TRUE, FALSE, NULL) extends classic Boolean algebra. In SQL: NULL AND FALSE = FALSE (short-circuit), but NULL AND TRUE = NULL (unknown), and NULL OR TRUE = TRUE (short-circuit). When writing database queries with nullable columns, always account for NULL propagation — it's one of the most common sources of subtle query bugs.
Karnaugh maps (K-maps) are a visual alternative to algebraic simplification for up to 4 variables. Arrange the truth table in a grid where adjacent cells differ by exactly one variable; circle groups of 1s in sizes of 1, 2, 4, or 8; each group corresponds to a simplified product term. Our calculator shows the K-map for expressions with 2-4 variables alongside the algebraic simplification.
Frequently Asked Questions
Boolean algebra is the hidden grammar of computing — from the logic gates in your CPU to the WHERE clause in your SQL to the search operators in Google. Our calculator makes this algebra visible, simplifying expressions, generating truth tables, and drawing the circuits your logic describes. Try it now and see what your conditions really mean.
Try this tool for free →open_in_new