Home › Developer Tools › Truth Table Generator

Truth Table Generator

Type a boolean or propositional logic expression in words or symbols. The generator builds the complete truth table with optional sub-expression columns, lists minterms and maxterms, writes the canonical DNF and CNF and tells you whether it is a tautology.

Last updated:

Use AND & && ∧ · *, OR | || ∨ +, NOT ! ~ ¬ or a postfix ', XOR ^ ⊕, NAND, NOR, XNOR, IMPLIES -> →, IFF <-> ↔, constants 0 1 true false.

Enter your values to see the result.
Advertisement
Advertisement

How to use the Truth Table Generator

  1. Type an expression such as (A AND B) OR NOT C or (p -> q) && !r. Put several expressions on separate lines to compare them.
  2. Choose the layout: column order, whether the first row is all false or all true, and 1/0 or T/F values.
  3. Press Generate Truth Table. The table updates as you type.
  4. Read the summary: how many rows are true, the minterm and maxterm lists and whether the expression is a tautology.
  5. Copy the DNF or CNF from the boxes under the table, or download the table as CSV.

Logical operators and how to type them

OperatorYou can typeTrue whenPrecedence
NOT (negation)NOT A, !A, ~A, ¬A, A'A is false1 (strongest)
AND (conjunction)AND, &, &&, ∧, ·, *both inputs are true2
NANDNAND, ↑not both inputs are true2
XOR (exclusive or)XOR, ^, ⊕, !=exactly one input is true3
XNORXNORboth inputs are equal3
OR (disjunction)OR, |, ||, ∨, +at least one input is true4
NORNOR, ↓both inputs are false4
IMPLIES (conditional)IMPLIES, ->, =>, →not (left true and right false)5, groups right to left
IFF (biconditional)IFF, <->, <=>, ↔, ==both sides have the same value6 (weakest)

Variable names can be words (rain AND cold) or letters. Tick Single-letter variables to read AB as A AND B, the way digital-logic textbooks write products. Note that ^ means XOR here, as in most programming languages; type ∧ or AND for conjunction.

Worked example: (A AND B) OR NOT C

#ABCA ∧ B¬CResult
0000011
1001000
2010011
3011000
4100011
5101000
6110111
7111101

The output is 1 in rows 0, 2, 4, 6 and 7, so the minterm list is Σm(0, 2, 4, 6, 7) and the maxterm list is ΠM(1, 3, 5). The canonical DNF has five terms, but the same function simplifies to just AB + C'.

Tips for building truth tables by hand

  • Count in binary. List rows 0 to 2ⁿ − 1; the last variable alternates every row, the one before it every two rows, and so on.
  • Add a column per sub-expression. Evaluate the innermost brackets first and build outwards; it makes mistakes easy to spot.
  • Use the cheap rows. An AND is 0 as soon as one input is 0, an OR is 1 as soon as one input is 1, and an implication is 1 whenever its left side is 0.
  • Check equivalences with two lines. De Morgan's laws, contrapositives (p → q vs ¬q → ¬p) and distributive laws can all be confirmed by comparing columns.

Frequently asked questions

How many rows does a truth table have?

A truth table with n variables has 2ⁿ rows, one for every combination of true and false. Two variables give 4 rows, three give 8, four give 16 and ten give 1,024. This generator supports up to 12 variables (4,096 rows).

What is the order of operations in boolean logic?

The usual precedence, from strongest to weakest, is NOT, AND, XOR, OR, IMPLIES and then IFF (biconditional). So A OR B AND C means A OR (B AND C), and p -> q -> r means p -> (q -> r). The tool shows the fully bracketed version of your expression so you can confirm how it was read.

When is an implication p → q false?

Only when p is true and q is false. In every other row, including both rows where p is false, the implication is true. That is why p → q is equivalent to ¬p ∨ q, which you can verify by entering both on separate lines.

What are minterms and maxterms?

A minterm is an AND of all variables (each plain or negated) that is true in exactly one row; the rows where the output is 1 give the minterm list Σm. A maxterm is an OR of all variables that is false in exactly one row; the rows where the output is 0 give the maxterm list ΠM. Row numbers are the binary value of the inputs with the first variable as the most significant bit.

What is the difference between DNF and CNF?

Disjunctive normal form (DNF) is an OR of AND terms, and the canonical DNF is the OR of all minterms. Conjunctive normal form (CNF) is an AND of OR clauses, and the canonical CNF is the AND of all maxterms. Both describe the same function; they are usually not the shortest form, which is what a boolean simplifier finds.

How do I check if two logic expressions are equivalent?

Enter each expression on its own line. Two expressions are logically equivalent when their output columns match in every row. The result cards say Equivalent or list the row numbers where they differ, which is a quick way to check De Morgan's laws or a homework answer.

What is a tautology?

A tautology is an expression that is true in every row, such as p ∨ ¬p or ((p → q) ∧ p) → q. A contradiction is false in every row, and anything in between is called contingent. An expression is satisfiable if at least one row is true.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Boolean Algebra SimplifierSimplify boolean expressions or minterm lists to minimal SOP and POS with Quine-McCluskey steps.Binary CalculatorAdd, subtract, multiply, divide, AND, OR, XOR and shift binary numbers with decimal values.Bitwise CalculatorCalculate AND, OR, XOR, NOT and bit shifts at 8–64 bits with a bit grid and all bases.Number Base ConverterConvert numbers between any bases from 2 to 36, with fractions and steps.Logic Grid PuzzlesSolve Einstein-style deduction puzzles with clues and an ✗/✓ grid, from easy to hard.Set CalculatorUnion, intersection, difference and complement of up to 4 sets, with a Venn diagram and counts.QR Code GeneratorMake QR codes for links, Wi-Fi, email and more.Barcode GeneratorCreate Code 128, EAN-13, UPC-A, EAN-8, Code 39 and ITF-14 barcodes as PNG or SVG.UUID GeneratorGenerate UUID v4 and v7 / GUIDs in bulk and copy or download them.Schema Markup Generator (JSON-LD)Create JSON-LD structured data for FAQ, Product, Article and more.Htaccess & Nginx Redirect GeneratorBuild 301 redirects for .htaccess, Nginx and Netlify or Cloudflare _redirects.Fake Data GeneratorGenerate mock data as JSON, CSV or SQL.Random String GeneratorGenerate secure random strings and tokens in bulk with any length and character set.API Key GeneratorCreate secure API keys and secrets with prefixes, checksums and SHA-256 hashes for storage.MIME Type LookupFind the MIME type for any file extension, or the extensions for a MIME type, in 400+ entries.Cron Expression GeneratorBuild crontab schedules visually, read them in plain English and see the next run times.URL Slug GeneratorTurn titles into clean, SEO-friendly URL slugs: accents, stop words, separators and bulk lines.JSON Schema GeneratorTurn sample JSON into a draft 2020-12 JSON Schema with types, required fields and formats.Gitignore GeneratorBuild a .gitignore from 50+ templates for languages, frameworks, IDEs and OS, merged and deduped.License GeneratorCreate a LICENSE file for MIT, Apache, GPL, BSD, ISC, MPL or Unlicense with your name and year.ULID GeneratorGenerate sortable ULIDs and UUID v7 in bulk, monotonic option, and decode their timestamps.Htpasswd GeneratorCreate .htpasswd entries with bcrypt, APR1-MD5 or SHA-1 for Apache and Nginx basic auth.Placeholder Image GeneratorCreate placeholder images in any size, color and text as PNG, JPG, WebP, SVG or data URI.Ads.txt GeneratorCreate or validate ads.txt and app-ads.txt files: seller lines, cert IDs and variables.Docker Run to Compose ConverterConvert docker run commands to docker-compose.yml, or a compose file back to docker run.Dockerfile GeneratorGenerate a production Dockerfile and .dockerignore for Node, Python, Go or a static nginx site.HTML Boilerplate GeneratorTick the options you need and get a clean HTML5 starter template with meta, OG tags and CSS reset.JSON to Zod SchemaInfer a Zod (or Yup) schema from sample JSON with optional, nullable and z.infer types.Linux Commands Cheat SheetSearchable Linux and bash command reference with flags explained, examples and copy buttons.LLMs.txt GeneratorBuild an llms.txt file for AI crawlers: summary and link sections, import from your sitemap.Nano ID GeneratorGenerate secure Nano IDs with custom alphabet, length and count, plus a collision calculator.Nginx Config GeneratorBuild an nginx server block: static site, SPA, reverse proxy or PHP, with SSL, gzip and redirects.OpenAPI / Swagger ViewerView OpenAPI 2/3 JSON or YAML as interactive API docs with validation and an endpoint list.package.json GeneratorFill a form and get a valid, npm-ready package.json with scripts, dependencies and checks.PKCE Code Challenge GeneratorGenerate an OAuth 2.0 PKCE code_verifier and S256 code_challenge, build auth URLs, verify pairs.README GeneratorFill in a form and get a polished README.md with badges, install, usage and license, live preview.Regex GeneratorBuild regular expressions visually from blocks or presets (email, date, phone) and test them live.Commit Message GeneratorBuild Conventional Commit messages with type, scope, body, breaking change and issue refs.GitLab CI Config GeneratorGenerate a .gitlab-ci.yml with stages, jobs, images, cache, artifacts and rules from templates.Jinja2 Template TesterRender Jinja2 templates with YAML or JSON variables using real Jinja2, with clear error lines.JSON Schema Mock Data GeneratorGenerate realistic sample JSON from a JSON Schema: formats, patterns, $ref, seeds and counts.Kubernetes Secret GeneratorCreate Kubernetes Secret YAML from key/value pairs or .env with auto base64, or decode one.Kubernetes YAML ValidatorValidate Kubernetes manifests against the API schema of a chosen version, with error paths.Prettier Config GeneratorToggle Prettier options, preview formatted code live and copy your .prettierrc file.Quartz Cron GeneratorBuild and explain Quartz and Spring cron expressions with seconds, ?, L, W and #, plus next fire times.README Badge GeneratorCreate Shields.io-style README badges for license, version, build and custom labels.Systemd Service File GeneratorCreate a systemd .service unit with ExecStart, user, restart policy, environment and hardening.tsconfig.json GeneratorBuild a tsconfig.json with target, module, strict checks and path aliases, each option explained.Access Log AnalyzerAnalyze Apache and Nginx access logs: top URLs, IPs, status codes, bots and traffic charts.Regex String GeneratorGenerate random test strings that match any regular expression, checked against the real regex.ASCII Table GeneratorTurn CSV or pasted cells into plain-text tables: MySQL, Markdown, Unicode box and reST styles.Database Schema DesignerDesign tables and relationships visually, then export SQL for MySQL, PostgreSQL or SQLite.Docker Compose GeneratorBuild a docker-compose.yml with a form: services, ports, volumes, env, healthchecks and presets.Dummy File GeneratorCreate test files of an exact size in KB, MB or GB with zeros, random bytes or text.FFmpeg Command GeneratorPick a task and options, get the exact ffmpeg command with every flag explained.Folder Tree GeneratorTurn a local folder or an indented list into an ASCII directory tree for your README.GitHub Actions Workflow GeneratorBuild a GitHub Actions CI workflow: triggers, matrix, caching, tests, Pages or Docker deploy.Kubernetes YAML GeneratorGenerate Deployment, Service, Ingress, ConfigMap, Secret and HPA manifests with safe defaults.Markdown TOC GeneratorGenerate a linked table of contents from Markdown headings with GitHub-style anchors.OpenAPI EditorEdit OpenAPI/Swagger YAML or JSON side by side with live API docs, validation and download.OpenAPI ValidatorValidate OpenAPI 3.0/3.1 and Swagger 2.0 specs: schema errors, broken $refs, line numbers.Pivot Table MakerBuild pivot tables from CSV or Excel by drag and drop: sum, count, average, charts, export.SQL Query BuilderBuild SELECT queries visually: joins, filters, GROUP BY, ORDER BY and LIMIT, as clean SQL.TypeScript PlaygroundWrite TypeScript with live type checking, see the compiled JavaScript and run it in your browser.Article Schema GeneratorCreate Article, BlogPosting or NewsArticle JSON-LD with headline, authors, dates and images.Event Schema GeneratorCreate Event JSON-LD with dates, venue or online location, tickets, organizer and performers.Google Search Query BuilderBuild advanced Google searches with site:, filetype:, intitle:, exact phrases and date operators.HowTo Schema GeneratorCreate HowTo JSON-LD with steps, tools, supplies, total time and cost, then copy it.
See all 85 Code Generators & Builders →