nubpaws.dev
Back to Articles
Series

Truth Table, CNF, and DNF Generator

A step-by-step series on building a truth table generator that computes Conjunctive and Disjunctive Normal Forms from scratch using vanilla JavaScript.

February 28, 2026 5 Chapters
Boolean Logic JavaScript Tutorial Parsing Series

About This Series

In this series we build a truth table generator that takes a boolean logic expression, parses it, evaluates every possible variable assignment, and produces both the Conjunctive Normal Form (CNF) and Disjunctive Normal Form (DNF) - all from scratch in vanilla JavaScript.

You can try the finished calculator here: Truth Table, CNF & DNF Generator, and the full source code is available on GitHub.

The series is structured as follows:

  1. Setting Up - writing the HTML/CSS and getting setup to write the actual complex bits.
  2. Tokenization - turning a raw string like (A & B) -> C into a stream of tokens.
  3. Parsing - building an Abstract Syntax Tree using recursive descent.
  4. Evaluation, Truth Tables, CNF & DNF - evaluating the AST for every assignment and extracting normal forms.
  5. The Math Behind It All - formal definitions and proofs for why the construction works.

By the end you will understand the full pipeline from user input to truth table and normal forms, and have the mathematical foundation to back it up.

Chapters