Truth Table
Build truth tables for AND, OR, NAND, NOR, XOR, XNOR, and NOT expressions. Free online truth table generator for computer science and digital electronics.
About This Calculator
The Truth Table Calculator generates complete truth tables for common boolean logic expressions involving two variables (A and B). Enter an expression using AND, OR, NAND, NOR, XOR, XNOR, or NOT and instantly see the output for all four combinations of A and B (True/True, True/False, False/True, False/False). The tool is designed for students learning discrete mathematics, programmers debugging logical conditions, and electronics enthusiasts verifying logic gate behavior.
Truth tables are fundamental tools in discrete mathematics, computer science, and digital electronics. They enumerate every possible input combination to a logic circuit and show the resulting output, making them essential for verifying logic gate behavior, simplifying boolean expressions, and teaching logic fundamentals. For two variables (A and B), there are exactly four possible input pairs, each yielding a boolean result based on the logical operator applied.
Each supported logic gate has a distinct truth table pattern. The AND gate outputs true only when both inputs are true. OR outputs true when at least one input is true. XOR (exclusive OR) outputs true when inputs differ. NAND (NOT AND) is the complement of AND, outputting false only when both are true. NOR (NOT OR) outputs true only when both are false. XNOR (exclusive NOR) outputs true when inputs match. NOT simply inverts a single variable. These seven gates form the complete set of fundamental boolean operations used in digital circuit design and algebraic logic.
The calculator parses your expression by normalizing whitespace and case, then matching against the known operator patterns. It evaluates the expression for each row in constant time without using JavaScript's eval(), ensuring safe and predictable behavior. The results display in a clear tabular breakdown showing the truth value of A, B, and the expression output for every combination. This tool is ideal for computer science students studying logic gates, programmers verifying conditional expressions, and hobbyists learning digital electronics fundamentals.
Frequently Asked Questions
How do I use the truth table calculator?
Type a boolean expression like A AND B, A OR B, A XOR B, A NAND B, A NOR B, A XNOR B, NOT A, or NOT B into the input field and click Generate Truth Table. The tool evaluates the expression for all four combinations of A and B (TT, TF, FT, FF) and displays the result for each row.
What boolean expressions are supported?
The calculator supports AND, OR, NAND, NOR, XOR, XNOR, and NOT (unary) operations between two variables A and B. Type expressions exactly as shown: A AND B, A OR B, A NAND B, A NOR B, A XOR B, A XNOR B, NOT A, NOT B.
What is a truth table used for?
Truth tables are used in digital logic design, computer architecture, and boolean algebra to enumerate all possible input combinations of a logic circuit and their corresponding outputs. They are essential for verifying logic gate behavior, simplifying expressions, and teaching discrete mathematics.
Is this truth table generator free?
Yes, all calculators on Calculy are completely free to use with no registration or hidden charges. You can bookmark or share your calculation via the URL.
Can I share my truth table results?
Yes, the URL automatically saves your expression so you can bookmark or share the exact truth table with anyone.
What is the difference between NAND and NOR?
NAND (NOT AND) outputs false only when both inputs are true; all other combinations output true. NOR (NOT OR) outputs true only when both inputs are false; all other combinations output false. Both are universal gates, meaning any other logic gate can be constructed using only NAND or only NOR gates.
Does the calculator support expressions with more than two variables?
Currently the calculator supports two-variable (A and B) boolean expressions. Each truth table has four rows representing all combinations of A and B (TT, TF, FT, FF). For more complex expressions with additional variables, you would need a dedicated multi-variable truth table generator.
What is the difference between XOR and XNOR?
XOR (exclusive OR) outputs true when the inputs are different (one true, one false). XNOR (exclusive NOR) outputs true when the inputs are the same (both true or both false). XNOR is the logical complement of XOR, meaning XNOR outputs the opposite of XOR for every input combination.