Boolean Expression Evaluator
Evaluate Boolean logic expressions with assigned true or false variable values. Use AND, OR, NOT, XOR, XNOR, NAND, NOR, parentheses and Boolean constants, then inspect the parsed expression and step-by-step evaluation.
eval().
—
—
—
—
Boolean Expression Evaluator
The Boolean Expression Evaluator calculates the true or false result of a logical expression after you assign Boolean values to its variables. It supports common operators including AND, OR, NOT, XOR, XNOR, NAND and NOR together with nested parentheses.
Unlike a truth table generator, which evaluates every possible variable combination, this tool evaluates one specific set of variable values at a time. For example, you can set A to true, B to false and C to true and immediately determine the result of a larger expression.
The evaluator also shows the detected variables, parser output and individual logic operations so you can verify how the final answer was obtained.
How to Evaluate a Boolean Expression
Enter an expression such as (A OR B) AND NOT C. The evaluator detects the variables automatically and displays True and False selectors for each one.
Choose the value of every variable and press Evaluate Boolean Expression. The final result and evaluation steps appear below.
Expression:
(A OR B) AND NOT C
Assignments:
A = TRUE
B = FALSE
C = FALSE
Evaluation:
A OR B
= TRUE OR FALSE
= TRUE
NOT C
= NOT FALSE
= TRUE
TRUE AND TRUE
= TRUE
Final result:
TRUEWhat Is a Boolean Expression?
A Boolean expression is a logical statement whose final value is either true or false. Expressions can contain Boolean variables, constants, operators and parentheses.
A AND B
NOT A
A XOR B
(A OR B) AND C
A AND (B OR NOT C)
(A NAND B) XOR CBoolean expressions are widely used in programming conditions, digital logic, search filters, permissions, electronic circuits and formal logic.
Boolean AND Evaluation
AND returns true only when both operands are true.
| A | B | A AND B |
|---|---|---|
| FALSE | FALSE | FALSE |
| FALSE | TRUE | FALSE |
| TRUE | FALSE | FALSE |
| TRUE | TRUE | TRUE |
Boolean OR Evaluation
OR returns true when at least one operand is true.
TRUE OR TRUE = TRUE
TRUE OR FALSE = TRUE
FALSE OR TRUE = TRUE
FALSE OR FALSE = FALSEBoolean NOT Evaluation
NOT is a unary operator. It reverses the Boolean state of the expression immediately following it.
NOT TRUE
= FALSE
NOT FALSE
= TRUE
NOT (A AND B)
= complement of the entire parenthesized resultBoolean XOR Evaluation
XOR, or exclusive OR, returns true when two operands have different Boolean values.
FALSE XOR FALSE = FALSE
FALSE XOR TRUE = TRUE
TRUE XOR FALSE = TRUE
TRUE XOR TRUE = FALSEBoolean XNOR Evaluation
XNOR is the complement of XOR. It returns true when both operands have the same Boolean value.
FALSE XNOR FALSE = TRUE
FALSE XNOR TRUE = FALSE
TRUE XNOR FALSE = FALSE
TRUE XNOR TRUE = TRUEFor this reason, XNOR is often described as a Boolean equivalence operation.
Boolean NAND Evaluation
NAND means NOT AND. It produces false only when both operands are true.
A NAND B
=
NOT (A AND B)
TRUE NAND TRUE
= FALSE
TRUE NAND FALSE
= TRUEBoolean NOR Evaluation
NOR means NOT OR. It evaluates to true only when both operands are false.
A NOR B
=
NOT (A OR B)
FALSE NOR FALSE
= TRUE
TRUE NOR FALSE
= FALSEUsing TRUE, FALSE, 1 and 0
The evaluator supports Boolean constants in addition to variables. TRUE and 1 are treated as true values, while FALSE and 0 represent false.
A AND TRUE
FALSE OR B
NOT 0
1 XOR A
A NAND TRUEConstants do not create variable controls because their values are already defined by the expression itself.
Boolean Expression Operator Precedence
When parentheses do not explicitly define the order of evaluation, the calculator uses a consistent Boolean precedence system.
| Priority | Operators | Meaning |
|---|---|---|
| 1 – Highest | NOT | Unary complement |
| 2 | AND, NAND | AND-family operations |
| 3 | XOR, XNOR | Exclusive comparison |
| 4 – Lowest | OR, NOR | OR-family operations |
Why Parentheses Matter
Parentheses explicitly define which expression should be evaluated first and are recommended whenever a Boolean expression contains several operators.
A OR B AND C
is evaluated as:
A OR (B AND C)
But:
(A OR B) AND C
evaluates the OR expression first.These two expressions can produce different results for the same variable assignments.
Nested Boolean Expressions
Parentheses can be nested to represent multiple levels of logical decision making.
Expression:
(A AND (B OR C)) XOR (NOT D)
Example assignments:
A = TRUE
B = FALSE
C = TRUE
D = FALSE
B OR C
= TRUE
A AND TRUE
= TRUE
NOT D
= TRUE
TRUE XOR TRUE
= FALSEBoolean Expression Evaluation Example
Consider the expression A AND (B OR NOT C).
A = TRUE
B = FALSE
C = FALSE
Step 1:
NOT C
= TRUE
Step 2:
B OR TRUE
= TRUE
Step 3:
A AND TRUE
= TRUE
Result:
TRUEBoolean Expression Evaluator vs Truth Table Generator
Both tools work with Boolean expressions, but they answer different questions.
| Tool | Purpose | Variable Values | Output |
|---|---|---|---|
| Boolean Expression Evaluator | Evaluate one specific case | User assigns each value | One final Boolean result |
| Truth Table Generator | Test every possible case | Automatically generates all combinations | Complete truth table |
Use this evaluator when you already know the values of the variables and need to determine whether the expression is true or false.
Boolean Expressions in Programming
Programming languages use Boolean expressions to control decisions, loops, validation, permissions and application state.
Conceptual condition:
LoggedIn AND (Admin OR Editor)
Example:
LoggedIn = TRUE
Admin = FALSE
Editor = TRUE
Result:
TRUEThe syntax used by actual programming languages varies, but the underlying Boolean logic follows the same truth rules.
Boolean Expressions in Digital Logic
Digital circuits can also be described with Boolean expressions. Variables represent logic-level inputs while operators correspond to logic gates.
Expression:
(A AND B) OR C
Possible gate structure:
A ──┐
AND ──┐
B ──┘ OR ── Output
C ────────┘Evaluating the expression for a chosen set of input states predicts the output of the corresponding combinational circuit.
Boolean Expressions for Permissions and Rules
Logical expressions are frequently used to represent access-control rules and feature conditions.
Expression:
Premium AND NOT Suspended
Premium = TRUE
Suspended = FALSE
Result:
TRUEMore complex policies can combine multiple conditions with nested AND, OR and NOT expressions.
Common Boolean Expression Errors
A common error is writing two variables next to one another without an operator, such as A B. The evaluator requires an explicit operator such as A AND B.
Another error is leaving an operator without a right-hand operand, such as A OR. Parentheses must also be balanced, so expressions such as (A AND B without a closing parenthesis are rejected.
NOT is unary and must appear before a variable, constant or parenthesized expression. For example, NOT A and NOT (A OR B) are valid.
Why This Evaluator Does Not Use eval()
The tool uses a dedicated tokenizer, operator-precedence parser and stack-based Boolean evaluator. Only the supported variables, constants, parentheses and Boolean operators are accepted.
This keeps expression interpretation limited to Boolean logic instead of executing arbitrary JavaScript code supplied in the input field.
Boolean Expression Evaluator Limitations and Notes
Variables are represented by individual letters A through Z. Operator names are case-insensitive, so A and B and A AND B are interpreted equivalently.
The evaluator is intended for Boolean logic rather than arithmetic comparison. Expressions such as A > 5, X == Y or numeric addition are outside the scope of this tool.
Each detected variable must be assigned either true or false. Constants TRUE, FALSE, 1 and 0 require no assignment.