ForHosting KIT · Engineering & construction

Boolean expression truth table calculator

Type a logic expression with AND, OR and NOT and get its complete truth table: A AND B gives four rows, with 1 only where both inputs are 1. Up to six variables and sixty-four rows, never a missed or flipped row. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Expression
A AND B
You get
Variables
A, B
Variable count
2
Row count
4

Students writing (A AND B) OR NOT C by hand often miss a row or flip a NOT; engineers scripting gate checks need a deterministic oracle that never invents XOR when only AND, OR and NOT were asked for. Parentheses control grouping; word forms AND, OR, NOT and the symbols &, |, !, &&, ||, ~ are all accepted. At most six variables keep the table at sixty-four rows so responses stay small for browsers and edge workers.

How the truth table is built from AND, OR and NOT

Operator precedence follows the usual convention that NOT binds tightest, then AND, then OR, so A OR B AND C is parsed as A OR (B AND C) unless you add parentheses. You may write operators as words (case-insensitive AND, OR, NOT) or as symbols: ampersand and double-ampersand for AND, vertical bar and double bar for OR, and bang or tilde for NOT. Parentheses force grouping exactly as in algebra.

Constants 0, 1, true and false are allowed when you need a fixed bit inside a larger formula. Variables are letter or alphanumeric identifiers such as A, B, enable or Q1; they are normalized to uppercase so a and A count as the same signal. For each integer mask from zero through two to the n minus one, the corresponding bits are assigned left-to-right to the sorted variable list (most significant bit on the leftmost variable), the expression is evaluated on that assignment, and the result bit is recorded.

The output is therefore a complete, ordered table you can print, grade against, or feed into a simulator without re-sorting rows yourself.

What to type, what you get and common mistakes

The example value A AND B is a two-variable conjunction; more interesting formulas use parentheses such as (A AND B) OR NOT C. Unexpected characters, unmatched parentheses, trailing tokens, and unsupported operators such as XOR or NAND also fail with a clear message so clients can fix the formula without guessing. Each row has values, an array of zero or one bits aligned with the variables list, and result, the evaluated output bit zero or one.

A short formula string restates the enumeration contract for display next to the table. Example: expression A AND B yields variables A and B, four rows, and result one only on the last row where both bits are one. Expression NOT A with a single variable yields two rows with inverted results.

Constant-only formulas such as TRUE OR FALSE produce zero variables, one row, and a single result bit. Failed validation is not billed.

Classroom and homework checks

Let students submit A AND B OR NOT C and verify all 2^n ordered rows against textbook hand calculations.

Small digital control conditions

Enumerate enable and mask logic written with AND, OR and NOT in firmware review scripts without a full HDL simulator.

How many variables can a formula use?

At most six distinct variables (64 rows). Variables are auto-detected from the expression and sorted alphabetically in the response.

How do I write (A AND B) OR NOT C?

Send expression as the string "(A AND B) OR NOT C" (or with & | !).

Which operator is applied first?

NOT binds tightest, then AND, then OR. So A OR B AND C is read as A OR (B AND C); add parentheses whenever you want a different grouping.

Can I use XOR or NAND?

No. Only AND, OR and NOT are supported, and XOR or NAND get a clear message instead of a guessed table. You can still build them, for example NAND as NOT (A AND B).

In what order are the rows listed?

In natural binary order. Variables are sorted alphabetically and the leftmost one is the most significant bit, so the table starts with all zeros and ends with all ones.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/elec/boolean-truth-table

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/elec/boolean-truth-table \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"expression":"A AND B"}'
{
  "expression": "A AND B"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "elec.boolean_truth_table",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Digital logic, exam prep, and hardware design all need a complete truth table for a Boolean expression of a few variables. This Boolean expression truth table calculator accepts a short formula, auto-detects the free variables, enumerates every assignment in natural binary order, and returns the result bit for each row.

How the truth table is built from AND, OR and NOT

A Boolean expression is a formula whose value is true or false for every combination of its free variables. This calculator supports the three classical operators used in every introductory digital-logic course: NOT (unary complement), AND (conjunction), and OR (disjunction). The engine collects every distinct variable, sorts them alphabetically for a stable column order, and rejects formulas with more than six free variables because a truth table grows as two to the n and would otherwise become huge for a lightweight parse endpoint.

Input contract, response shape, and error behaviour

POST a JSON body with one required string field: expression. Empty strings, missing fields, and non-string types fail with invalid_input naming the field. On success the body echoes the original expression string, lists variables in sorted order, reports variable_count and row_count (always two to the power of variable_count), and provides truth_table as an array of objects. Keep formulas short (a few hundred characters at most); this endpoint is a pure truth-table engine, not a general computer-algebra system, and it does not simplify expressions into sum-of-products form or draw Karnaugh maps—those are separate product ideas if you need them later.

Where a Boolean truth-table API earns its keep

Exam and LMS auto-graders need a deterministic oracle that marks a missing row or a wrong result bit without depending on a full symbolic suite. Invalid formulas do not consume balance. Classrooms and tutoring platforms embed a Boolean expression truth table calculator so learners can check every row of (A OR B) AND NOT C without flipping signs on paper. Hardware and firmware teams often reduce a small control condition to AND, OR and NOT when reviewing enable logic or interrupt masks; calling a tiny parse API avoids pulling a heavy solver for a six-variable table. Pin the ordered truth_table in tests, keep variable names stable by relying on alphabetical sort, and you get reproducible tables for homework plugins, edge workers, and documentation generators without standing up a digital-logic toolchain of your own.

Exam and LMS auto-grading

Score Boolean truth-table items with a deterministic oracle that rejects bad syntax and never invents unsupported operators.

Which Boolean operators are supported?

AND, OR and NOT only—as words (case-insensitive) or symbols (&, &&, |, ||, !, ~). Parentheses group subexpressions. XOR, NAND, NOR and XNOR are rejected with invalid_input.

What does the truth_table field contain?

An array of rows. Each row has values (0/1 bits aligned with the variables array) and result (the evaluated output bit 0 or 1). Rows run in natural binary order.

What does the Boolean truth table calculator cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →