Generate a Boolean truth table

Evaluate every true-and-false assignment for a Boolean expression containing AND, OR, XOR, NOT, and parentheses.

freeworks offlinenothing uploaded
ToolTruth Table Generator
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

A tokenizer recognizes variable names, parentheses, word operators, and the aliases &, |, ^, and !; recursive-descent parsing applies NOT before AND, AND before XOR, and XOR before OR. The parsed expression is evaluated for all 2ⁿ assignments from the all-true row to the all-false row.

Formula
row count = 2ⁿ for n distinct variables
  • No expression is assumed, and six variables cap the visible output at 64 rows.
  • Variable order follows first appearance in the expression.

Worked example

Two variables with AND
Input
											p AND q
										
Output
												Table: p q | Result
T T | T
T F | F
F T | F
F F | F
Variable count: 2
Row count: 4
True count: 1
False count: 3
											

When to use this

Propositional-logic exercises classify assignments, digital-logic design checks gate combinations, and software reviews compare condition columns for logical equivalence.

Edge cases

  • p OR q AND r means p OR (q AND r) because AND binds more tightly; add parentheses to request (p OR q) AND r.
  • p XOR q XOR r parses from the left, while Boolean XOR’s associativity means the final parity column is unchanged.
  • Seven distinct variables would produce 128 rows and are rejected by the six-variable readability cap.