Developer Tools· 5 min read

Truth Table Generator: Boolean Logic Tables for Up to 3 Variables

Enter a boolean expression with AND, OR, NOT, implies, and iff operators to generate a complete truth table with all possible input combinations.

By EasyDevTools Team Last updated: 2026-08-24

What a truth table is and when you need one

A truth table enumerates every possible combination of input values for a boolean expression and shows the output for each combination. For an expression with three variables P, Q, and R, there are two to the power of three (eight) rows, each representing a unique assignment of true or false to the variables. Truth tables are fundamental tools in digital logic design, formal verification, database query optimization, and academic courses on discrete mathematics.

The Truth Table Generator at /developer-tools/validators/truth-table-generator takes a boolean expression using variables P, Q, and R and operators like AND, OR, NOT, implies, and iff, then computes the output for all input combinations and displays the results in a clear table format.

See it in action

Supported operators and syntax

The generator accepts both Unicode symbols and ASCII alternatives for each operator:

AND: the Unicode symbol (wedge) or `&&`.

OR: the Unicode symbol (vee) or `||`.

NOT: the Unicode symbol (negation) or `!`.

Implies: the Unicode right arrow symbol or you can describe it in the expression.

Iff (if and only if): the Unicode double arrow symbol.

The ASCII alternatives (`&&`, `||`, `!`) are convenient because they do not require typing special Unicode characters. The implies operator is internally rewritten as `(!a || b)`, which is the standard material implication equivalence. The iff operator is rewritten using strict equality.

How expressions are evaluated

Each row of the truth table is generated by substituting true or false values for each variable, then evaluating the resulting expression using JavaScript's native `&&`, `||`, and `!` operators. The implies operator is first rewritten: `a implies b` becomes `(!a || b)`. The iff operator is rewritten as `(a === b)`. This approach leverages JavaScript's boolean coercion, which is reliable for pure boolean inputs.

The generator does not parse operator precedence in a custom way. It relies on JavaScript's built-in operator precedence, which matches standard boolean logic conventions: NOT binds tightest, then AND, then OR. For complex expressions, use parentheses to make the intended grouping explicit.

Variable limits and table size

The generator supports up to three variables: P, Q, and R. With three variables, the truth table has eight rows. Adding a fourth variable would produce 16 rows, a fifth would produce 32, and so on. The exponential growth is why the limit is set at three: beyond that, the table becomes large and the output is harder to scan visually.

For most educational and practical purposes, three variables are sufficient. If you need to evaluate a four-variable expression, you can split it into sub-expressions and evaluate each separately, combining the results manually.

Example truth tables

ExpressionPQResult
P AND QTTT
P AND QTFF
P AND QFTF
P AND QFFF
P implies QTTT
P implies QTFF
P implies QFTT
P implies QFFT

Step-by-step: generating a truth table

Select the variables you need: P only, P and Q, or P, Q, and R.

Enter your boolean expression in the input field using the supported operators.

Click Generate table.

Review the complete truth table showing all input combinations and outputs.

The entire computation runs in your browser. No expression data is uploaded. For related developer tools, see /blog/regex-tester for pattern matching, /blog/jsonpath-tester for JSON queries, /blog/cron-parser for schedule expressions, and /blog/number-base-converter for base conversions.

Applications in digital logic and computer science

Truth tables are used to define the behavior of logic gates (AND, OR, NOT, NAND, NOR, XOR, XNOR) and to verify that a combinational logic circuit meets its specification. In digital design, you write a truth table for the desired behavior, then derive a boolean expression (often using Karnaugh maps or Quine-McCluskey minimization) and implement it with gates.

In computer science, truth tables are used to prove logical equivalences (for example, De Morgan's laws), to check whether an argument is valid, and to understand the semantics of programming language operators like short-circuit evaluation. In database systems, truth tables underpin SQL's three-valued logic with NULL.

Common logical equivalences verified with truth tables

De Morgan's Law: NOT (P AND Q) equals (NOT P) OR (NOT Q). Generate both tables and compare.

Double negation: NOT (NOT P) equals P. Every row matches.

Contrapositive: P implies Q is equivalent to (NOT Q) implies (NOT P). Both tables are identical.

Distributive law: P AND (Q OR R) equals (P AND Q) OR (P AND R).

These equivalences are the building blocks of boolean algebra and are used constantly in circuit simplification, query optimization, and formal verification.

Privacy: local evaluation only

Expression evaluation happens entirely in your browser. No expression data is sent to any server.

Visit /about to learn more about EasyDevTools's privacy-first approach to developer tools.

Frequently asked questions

Q: Which operators are supported?

A: AND (wedge or &&), OR (vee or ||), NOT (negation or !), implies (right arrow), and iff (double arrow). Both Unicode symbols and ASCII operators work.


Q: How are expressions evaluated?

A: Each row substitutes variable values (true/false) and uses JavaScript's `&&`, `||`, `!` operators. The implies operator is rewritten as `(!a || b)` and iff as `(===)`.


Q: What is the max number of variables?

A: Three (P, Q, R), giving up to 8 rows. More variables would grow the table exponentially.


Q: Is my expression uploaded?

A: No. Evaluation happens entirely in your browser.

Need help using this tool?

Read our complete Truth Table Generator tutorial for step-by-step guidance.

Ready to try the tool?

No accounts. No uploads. No limits. Start now.