Developer tool

Logic Truth Table Generator

Enter a Boolean expression using variables A–Z, parentheses, !, &, |, ^, -> and <->.

Runs in your browser. No upload.

Values are processed locally in this browser.

Result

—

About this tool

Logic Truth Table Generator made simple.

The expression is parsed as Boolean logic locally and is never executed as JavaScript. Operator precedence is shown in the help beneath the tool.

Guide

Using Logic Truth Table Generator

The Logic Truth Table Generator builds a table for a Boolean expression. You type something like A & !B, and it lists every mix of 0 and 1 for the letters and the result for each row. It accepts up to six different variables and the operators not, and, or, xor, implies and if-and-only-if. It reads the text as logic and never runs it as code, and it does not simplify the expression.

How to use it

  1. Type an expression using single letters as variables, the constants 0 and 1, brackets, and the operators ! & | ^ -> <->. The symbols ¬ ∧ ∨ ⊕ are accepted as well, and so are the arrow symbols for implies and if-and-only-if.
  2. Press Calculate. The result shows a header row with the variables in alphabetical order, then one row per combination, ending with a Result column.
  3. Read 1 as true and 0 as false. Press Copy result to copy the table as plain text.
  4. If you get an error, check the brackets and make sure each operator has something on both sides. When unsure about the order, add brackets.

Worked examples

A and not B

You enter
Expression
A & !B
You get
Rows
A B | Result; 0 0 | 0; 0 1 | 0; 1 0 | 1; 1 1 | 0

The result is true only when A is true and B is false. That is the single row 1 0, so the Result column has one 1.

Run through the tool’s own code.

Implication

You enter
Expression
A -> B
You get
Rows
A B | Result; 0 0 | 1; 0 1 | 1; 1 0 | 0; 1 1 | 1

A -> B is false only when A is true and B is false. If A is false the statement counts as true whatever B is.

Run through the tool’s own code.

Which operator binds first

You enter
Expression
A ^ B | C
You get
Rows
A B C | Result; 0 0 0 | 0; 0 0 1 | 1; 0 1 0 | 1; 0 1 1 | 1; 1 0 0 | 1; 1 0 1 | 1; 1 1 0 | 0; 1 1 1 | 1

The tool groups ^ before |, so this reads (A xor B) or C. In row 1 1 0 the xor is 0 and C is 0, which gives 0. Other tools may group these two differently.

Run through the tool’s own code.

Chained implications group to the right

You enter
Expression
A -> B -> C
You get
Row 0 0 0
1
Row 1 1 0
0
Meaning
A -> (B -> C)

With A = 0, B = 0, C = 0 the inner part B -> C is true, so the whole statement is true. Grouping to the left, (A -> B) -> C, would give 0 in that row, so the grouping matters.

Run through the tool’s own code.

Two expressions that always agree

You enter
Expression
!A & !B <-> !(A | B)
You get
Result column
1; 1; 1; 1

A column of all 1s means the two sides match in every row. This is one of De Morgan's laws, and the table confirms it for all four combinations of A and B.

Run through the tool’s own code.

When it helps

  • Check homework on logic, discrete maths or digital circuits by comparing your hand-made table with the tool's.
  • See whether two Boolean expressions are the same by joining them with <-> and looking for a column of 1s.
  • Test the condition of an if statement in code, to find which input combinations make it true.
  • Spot a tautology, an expression that is true in every row, or a contradiction that never is.

Limits to keep in mind

  • At most six different variables are allowed, which gives 64 rows. A seventh letter or an expression with no letters gives the message "Use 1–6 distinct variables."
  • Variables are single letters. The page says A–Z, but lowercase letters are also read, and a and A count as two separate variables, so keep to one case.
  • Only the symbols listed are understood. Words such as AND or NAND, numbers other than 0 and 1, and other signs give an error. The tool shows the table but does not simplify, draw gates or make a Karnaugh map.
  • The result is plain text with no colour or grid, and there is no way to show only the rows where the result is 1.

Tips

  • Add brackets around anything you are not sure about, so your table matches the meaning you had in mind.
  • Order from tightest to loosest is !, &, ^, |, ->, <->, which is also printed under every table.
  • To test whether two expressions are equal, put <-> between them in brackets and check that the Result column is all 1s.

Common questions

About Logic Truth Table Generator.

Which operators can I use, and in what order do they apply?

You can use ! (not), & (and), | (or), ^ (xor), -> (implies) and <-> (if and only if). From tightest to loosest the tool applies them in the order !, &, ^, |, ->, <->. Brackets always come first, so use them whenever the order is unclear.

How do I tell if an expression is always true?

Look at the Result column. If every row shows 1, the expression is true for all combinations, which logicians call a tautology. If every row shows 0 it is a contradiction. A mix of 0 and 1 means the result depends on the inputs.

What does the arrow -> mean?

It means implies, as in if A then B. The statement is false only when A is true and B is false. When A is false it is true no matter what B is. The tool groups a chain like A -> B -> C to the right.

Is my expression run as JavaScript?

No. The page says the text is parsed locally as Boolean logic and is never executed as code. The tool breaks it into allowed pieces and rejects anything else, which is why unknown symbols return an error instead of doing something.

How many variables can I use?

Between one and six different letters. The columns are sorted alphabetically, and every extra variable doubles the number of rows, so six variables give 64 rows. An expression made only of 0 and 1 has no variable and is refused.

Can I type 0 and 1 inside the expression?

Yes. The tool reads 0 as false and 1 as true, so A & 1 behaves like A. The help line on the page lists only letters and operators, but constants are accepted by the code, as long as at least one letter is present.

How do I use Truth table generator?

Enter a Boolean expression using variables A–Z, parentheses, !, &, |, ^, -> and <->.

Is my data uploaded to a server?

No. This tool runs locally in your browser. Your input is not uploaded.