Free online calculator

De Morgan Calculator

Apply De Morgan’s laws to Boolean expressions and verify the equivalent result with a complete truth table.

Boolean logic · Truth tables · NNF

De Morgan calculator

Negate AND/OR expressions, push NOT to individual variables, and verify the equivalent form with a complete truth table.

Parsed safely · Instant · Explained
1
Choose the expression inside NOTNegating AND changes it to OR; negating OR changes it to AND.
Logic made visible

What is a De Morgan calculator?

A De Morgan calculator rewrites the negation of an AND/OR expression without changing its truth value. It moves NOT through a group, switches AND to OR or OR to AND, and negates every operand. This page also produces a truth table so the original negation and transformed expression can be checked row by row.

If you searched for a “Morgan calculator,” the standard mathematical name is De Morgan’s Law calculator, after the logician Augustus De Morgan.

1Flip the operatorAND becomes OR, and OR becomes AND.
2Negate every partThe outer NOT distributes to each operand.
3Verify every rowMatching truth-table columns establish equivalence.
The two identities

De Morgan’s laws for Boolean logic

Negation of AND¬(A ∧ B) ≡ ¬A ∨ ¬B

“Not both” means at least one operand is false.

Negation of OR¬(A ∨ B) ≡ ¬A ∧ ¬B

“Neither” means both operands are false.

The same transformation extends to more operands and nested groups. Each time a negation crosses an AND/OR operator, the operator changes and the negation continues inward.

Calculation methodology

How the expression transformer works

01
Tokenise safely

A restricted parser accepts variables, constants, NOT, AND, OR and parentheses. It does not execute the text as code.

02
Build the expression tree

NOT has the highest precedence, then AND, then OR. Parentheses override that order.

03
Negate the complete tree

At every AND/OR node, De Morgan’s law flips the operator and passes negation to both branches. Double negations cancel.

04
Generate and compare truth values

The tool evaluates both forms for every possible variable assignment and reports whether all rows match.

Worked examples

De Morgan transformation examples

Two inputs¬(A ∧ B)¬A ∨ ¬B

The AND flips to OR and both inputs are negated.

Three inputs¬(A ∨ B ∨ C)¬A ∧ ¬B ∧ ¬C

Every OR becomes AND under the outer negation.

Nested expression¬(A ∧ (B ∨ C))¬A ∨ (¬B ∧ ¬C)

The outer AND flips first; the nested OR flips when its negation moves inward.

Existing NOT¬(¬A ∨ B)A ∧ ¬B

The double negation on A cancels.

Where the laws are used

Logic, programming, gates and sets

Programming conditions!(isAdmin && isActive)!isAdmin || !isActive

These are equivalent in ordinary two-valued Boolean logic.

Digital logic

A negated AND is a NAND operation; De Morgan’s law shows its equivalent OR gate with inverted inputs. The dual relationship applies to NOR.

Set theory(A ∪ B)ᶜ = Aᶜ ∩ Bᶜ(A ∩ B)ᶜ = Aᶜ ∪ Bᶜ

Union corresponds to OR, intersection to AND, and complement to NOT.

Search filters and rules

Negated filters can be rewritten so exclusions apply to individual conditions, but systems with NULL or unknown values need their own semantics.

Avoid common mistakes

The operator must change

¬(A ∧ B) ≠ ¬A ∧ ¬B

Negating the inputs without swapping AND to OR is not equivalent.

¬(A ∨ B) ≠ ¬A ∨ ¬B

Negating an OR group requires AND between the negated inputs.

Flip the connector and negate every operand

Both actions are required at each crossed AND or OR.

Learning references

Sources supporting the method

Frequently asked questions

De Morgan calculator FAQs

What are De Morgan’s two laws?

The negation of A AND B is equivalent to NOT A OR NOT B. The negation of A OR B is equivalent to NOT A AND NOT B.

How do I use this De Morgan calculator?

Use the explorer for the two basic laws, or choose the expression transformer, enter a Boolean expression, and calculate. The tool negates the whole expression, produces negation normal form and builds a truth table.

Which Boolean operators can I enter?

Use !, ~ or ¬ for NOT; &, * or ∧ for AND; and |, + or ∨ for OR. Parentheses and Boolean constants 0 and 1 are also supported.

What is negation normal form?

Negation normal form, or NNF, uses only AND, OR and NOT, with every NOT applied directly to a variable or constant rather than to a grouped expression.

Why does AND change to OR?

For NOT(A AND B) to be true, at least one of A or B must be false. That condition is expressed as NOT A OR NOT B.

Why does OR change to AND?

For NOT(A OR B) to be true, both A and B must be false. That condition is expressed as NOT A AND NOT B.

Can the calculator handle nested parentheses?

Yes. It parses nested groups and recursively pushes the outer negation inward, switching every crossed AND or OR and cancelling double negations.

How many variables are supported?

The truth-table generator supports up to six distinct single-letter variables, producing at most 64 input rows.

Does the calculator execute my expression as code?

No. A restricted purpose-built parser reads only the documented Boolean tokens. The plugin does not use eval or execute the entered expression.

How are De Morgan’s laws used in programming?

They help rewrite negated compound conditions. For example, NOT(A AND B) can be expressed as NOT A OR NOT B. Language-specific short-circuit, null and type rules still apply.

Do De Morgan’s laws apply to sets?

Yes. The complement of a union equals the intersection of the complements, and the complement of an intersection equals the union of the complements.

Are my Boolean expressions stored?

No. Parsing, transformation and truth-table generation happen locally in the browser, and the plugin does not transmit or store the entered expression.