Runs in browserNo data sent to server
Examples
Gates

What Is a Truth Table?

A truth table is a mathematical table used to determine whether a boolean expression is true or false for all possible combinations of its input variables.

For n variables, a truth table has 2n rows. A 2-variable expression has 4 rows, a 3-variable expression has 8 rows, and an 8-variable expression has 256 rows. This tool generates the full table for any expression with up to 8 variables.

Boolean Operators Reference

  • AND (∧) — true only when both inputs are true
  • OR (∨) — true when at least one input is true
  • NOT (¬) — inverts the value (true → false)
  • XOR (⊕) — true when inputs are different
  • NAND — NOT AND (opposite of AND)
  • NOR — NOT OR (opposite of OR)
  • — implication (if A then B)
  • — biconditional (A if and only if B)

What Is a Karnaugh Map?

A Karnaugh map (K-Map) is a visual method for simplifying boolean expressions. It arranges truth table rows in a grid where adjacent cells differ by only one variable — allowing you to identify and eliminate redundant terms visually. K-Maps are used in digital circuit design to minimize logic gates. This tool generates the K-Map automatically from your expression.

What Are Minterms and Maxterms?

A minterm is a product (AND) term where the expression equals 1. A maxterm is a sum (OR) term where the expression equals 0.

SOP (Sum of Products) is the sum of all minterms. POS (Product of Sums) is the product of all maxterms. Both are canonical forms that represent any boolean function completely and unambiguously.

Frequently Asked Questions

How do I generate a truth table online?
Type or paste your boolean expression using the operator buttons — AND (∧), OR (∨), NOT (¬), XOR (⊕), NAND, NOR — then click Generate. The tool produces the complete truth table for all variable combinations, plus Karnaugh map, minterms, maxterms, and SOP/POS forms.
What is the difference between SOP and POS forms?
SOP (Sum of Products) expresses a boolean function as an OR of AND terms — one AND term for each row where the output is 1 (minterms). POS (Product of Sums) expresses it as an AND of OR terms — one OR term for each row where the output is 0 (maxterms). Both are complete canonical representations of the same function.
How do I use a Karnaugh map to simplify a boolean expression?
The K-Map groups adjacent cells where the output is 1 into rectangles of size 1, 2, 4, or 8. Each group eliminates one variable. The simplified expression is the OR of all group terms. This tool generates the K-Map automatically from your expression.
What is De Morgan's law?
De Morgan's laws state that NOT(A AND B) equals (NOT A) OR (NOT B), and NOT(A OR B) equals (NOT A) AND (NOT B). They allow conversion between AND and OR forms and are fundamental to digital circuit design and boolean simplification. Try the "De Morgan" example in the tool to see them in action.
How many variables can this truth table generator handle?
Up to 8 variables, producing truth tables with up to 256 rows. Most classroom problems use 2–4 variables (4–16 rows). The tool handles everything from simple 2-variable expressions to complex 8-variable digital logic circuits.

Related Tools

Other developer and CS tools that pair well with boolean logic and truth tables:

All parsing and generation runs in your browser.

What Is a Truth Table Generator?

A truth table generator takes a boolean expression with named variables and produces a table showing the output value for every possible combination of inputs. For n variables there are 2^n rows — 2 rows for 1 variable, 4 for 2, 8 for 3, up to 256 rows for 8. Truth tables are the foundation of digital logic design, computer architecture, and formal logic analysis.

This tool goes beyond a basic table: it also produces a Karnaugh map for visual simplification, extracts minterms and maxterms, outputs Sum of Products (SOP) and Product of Sums (POS) canonical forms, and exports working boolean functions in JavaScript, Python, Java, and Go.

How it works

Generate a Truth Table in Seconds

01

Enter your expression

Type a boolean expression using the operator buttons: AND (∧), OR (∨), NOT (¬), XOR (⊕), NAND, NOR, implication (→), biconditional (↔). Use any single-letter variable names.

02

Click Generate

The tool parses your expression, identifies variables, and generates all 2^n input combinations and their output values.

03

Explore the output

View the truth table, Karnaugh map, minterms (rows where output is 1), maxterms (rows where output is 0), and SOP/POS canonical forms.

04

Export code

Copy the boolean function as a working if-statement in JavaScript, Python, Java, or Go — ready to paste into your project.

Use cases

Who Uses a Truth Table Generator?

🎓

Computer Science Students

Verify homework answers for digital logic, discrete math, and boolean algebra assignments.

💡

Digital Logic Design

Design and verify combinational circuits before implementing in hardware or HDL.

🔍

Expression Simplification

Use the Karnaugh map output to find the minimal SOP form for a complex boolean function.

🐛

Debug Conditional Logic

Test all branches of a complex boolean condition to ensure your if-else chain handles every case.

📝

Formal Logic Analysis

Evaluate propositional logic tautologies, contradictions, and logical equivalences.

Code Generation

Get working boolean functions in your target language rather than manually translating SOP expressions.

Supported Operators & Syntax

OperatorSymbolMeaning
AND∧ or &True when both operands are true
OR∨ or |True when at least one operand is true
NOT¬ or !Negation — true when operand is false
XOR⊕ or ^Exclusive OR — true when exactly one is true
NANDNOT AND — false only when both are true
NORNOT OR — true only when both are false
ImplicationA → B: false only when A is true and B is false
BiconditionalTrue when both have the same value (XNOR)
FAQ

Frequently Asked Questions

1How do I generate a truth table online?
Type your boolean expression using the operator buttons — AND (∧), OR (∨), NOT (¬), XOR (⊕) — then click Generate. The tool produces the complete truth table plus Karnaugh map, minterms, maxterms, and SOP/POS canonical forms.
2What is the difference between SOP and POS boolean forms?
SOP (Sum of Products) is an OR of AND terms — one term per row where output is 1 (minterms). POS (Product of Sums) is an AND of OR terms — one term per row where output is 0 (maxterms). Both are complete canonical forms of the same function.
3What is a Karnaugh map?
A K-Map is a visual method for simplifying boolean expressions. It arranges truth table rows in a grid where adjacent cells differ by one variable — allowing you to visually identify redundant terms that can be eliminated.
4What are minterms and maxterms?
A minterm is an AND term for each row where output equals 1. A maxterm is an OR term for each row where output equals 0. Together they form the SOP and POS canonical forms.
5How many variables can this tool handle?
Up to 8 variables, producing tables with up to 256 rows. Most classroom problems use 2–4 variables (4–16 rows).
6What is a truth table in digital logic?
A truth table lists all possible input combinations for a boolean expression and their output values. For n variables there are 2^n rows. Truth tables describe logic gate and circuit behavior in digital electronics and discrete mathematics.
7How do I check if two boolean expressions are equivalent?
Generate truth tables for both expressions and compare their output columns. If outputs match for every input row, the expressions are logically equivalent. The XOR of two equivalent expressions produces constant 0.
8How do I simplify a boolean expression using a truth table?
Generate the truth table to find all minterms (output = 1 rows). Use the Karnaugh map to group adjacent minterms into rectangles of 1, 2, 4, or 8. Each rectangle eliminates variables, producing a minimal SOP expression.
9What is a tautology in propositional logic?
A tautology is a boolean expression always true regardless of inputs — its truth table output column contains only 1s. A contradiction is always false (all 0s). A contingency is sometimes true, sometimes false.
10What is De Morgan's law?
De Morgan's laws: NOT(A AND B) = (NOT A) OR (NOT B), and NOT(A OR B) = (NOT A) AND (NOT B). They transform between SOP and POS forms and simplify NAND/NOR circuits. Verify by generating truth tables for both sides.
11Can I export the truth table as code?
Yes. Click Code Export and choose JavaScript, Python, Java, or Go. The tool outputs a working boolean function implementing your exact expression — ready to paste into your project.
12How do I enter a boolean expression with AND, OR, and NOT?
Use the operator buttons: ∧ for AND, ∨ for OR, ¬ for NOT, ⊕ for XOR, ↑ for NAND, ↓ for NOR. Or type &, |, and !. Parentheses are supported: (A ∨ B) ∧ ¬C.
Learn more

Developer Guides

Feedback for truth_table_generator

Tell us what's working, what's broken, or what you wish we built next — it directly shapes our roadmap.

You make the difference

Good feedback is gold — a rough edge you hit today could be smoother for everyone tomorrow.

  • Feature ideas often jump the queue when lots of you ask.
  • Bug reports with steps get fixed faster — paste URLs or examples if you can.
  • Name and email are optional; we won't use them for anything except replying if needed.

Stay Updated

Get the latest tool updates, new features, and developer tips delivered to your inbox.

What you'll get
  • Product updates & new tools
  • JSON, API & developer tips
  • Unsubscribe anytime — no hassle

Get in touch

Feature ideas, bugs, or a quick thanks — we read every message.