Karnaugh Map Solver

Free online Karnaugh map solver: type a Boolean expression of two to six variables and get its K-map with every group ringed and the minimal sum of products or product of sums read off it.

Input a logical expression to analyze it (supports propositional logic, Boolean algebra)

Client-side only - your data never leaves your browser

Guide

Click an operator to try its example in the calculator. Each one shows every way you can type it.

Type an expression and this Karnaugh map solver lays its truth values out on a Gray-coded grid, rings every group that can be merged, and reads the minimal form off them. It takes symbols (¬ ∧ ∨ → ↔) or plain ASCII (!, &, |, ->, <->), covers two to six variables, and works out an exact minimum rather than a merely good one. Nothing is uploaded: the map is built in your browser.

How to solve a Karnaugh map

  1. Type your expression into the field above - (A & B) | (!A & C), for example. The operator keyboard inserts the symbols if you would rather not type them.
  2. The solver reads the variables off the expression and lays the truth values out on the grid. The axes are Gray-coded (00, 01, 11, 10), so neighbouring cells differ in exactly one variable - which is what makes a group of them collapse into a single term.
  3. Each coloured ring is a group. Hover or tap one in the legend to pick it out on the map, and note the ones marked essential: those are the groups no minimal form can leave out. A group may wrap around the edges of the map, and a cell may belong to more than one.
  4. Read the minimal form underneath. Switch between sum of products and product of sums, copy the result, load it back into the calculator, or export the map as LaTeX or TikZ.

What the solver gives you

  • Every group ringed and colour-coded, with the essential ones marked and the term each one leaves behind.
  • A minimal form that is genuinely minimal: the cover is searched exactly, not picked greedily, so a cyclic map still comes out shortest.
  • Sum of products or product of sums - group the ones or group the zeros - from the same map.
  • The map as LaTeX, either as a plain table or redrawn in TikZ with its rings and its legend.
  • The truth table, the properties and the equivalent forms too, if you open the same expression in the full calculator.
Open the Logic Calculator

A worked example

The map for (((A∧B)∧C)∨((A∧B)∧¬C))∨((¬A∧B)∧C). Three cells are true, and they are covered by two groups of two that overlap in one of them - which is the whole method in miniature: the variable that changes inside a group drops out of its term, and a cell may be covered twice.

Karnaugh map

Each coloured group covers a rectangle of true cells. The variables that change inside a group drop out, so every group leaves one conjunction behind. How to read this map →

Karnaugh map with A down the rows and BC across the columns
ABC00011110
0⊥⊥⊤⊥
1⊥⊥⊤⊤
Minimal form
(B ∧ C) ∨ (A ∧ B)

Groups

How many variables can a Karnaugh map have?

This solver draws maps for 2 to 6 variables. Below 2 there is nothing to group; five and six are drawn as two or four stacked planes, and above 6 even that stops being easier to read than the truth table beside it. For more variables, the calculator's equivalent forms still give you a minimized DNF.

VariablesCellsGrid
242 × 2
382 × 4
4164 × 4
5322 × (4 × 4)
6644 × (4 × 4)

Sum of products and product of sums

Grouping the true cells gives a sum of products: one conjunction per group, ORed together. Grouping the false cells instead gives a product of sums, with the literals negated on the way out: one disjunction per group, ANDed together. They describe the same function, and which one is shorter depends on whether the ones or the zeros form the tidier rectangles - so the solver offers both and you take the smaller.

Truth Table to ExpressionConvert any truth table into a logical expression. Generate Boolean formulas in Disjunctive Normal Form (DNF) or Conjunctive Normal Form (CNF) from your custom truth table.

Frequently Asked Questions

Find answers to common questions about using the Logic Calculator

How many variables can a Karnaugh map have?

This solver draws maps for two to six variables. Two variables give a 2 × 2 grid, three a 2 × 4, four a 4 × 4. Five and six are drawn the way textbooks draw them, as two or four stacked 4 × 4 planes, with cells in the same position on neighbouring planes counted as adjacent - a group that does not mention the stacking variables is the same rectangle on every sheet. Past six, the adjacencies you have to hold in your head stop being visible, which is the only thing a map is for: use the minimized DNF in the calculator's equivalent forms instead.

What is the difference between sum of products and product of sums?

They are two ways of reading the same map. Grouping the true cells gives a sum of products - one conjunction per group, ORed together. Grouping the false cells gives a product of sums, with the literals negated as they come out - one disjunction per group, ANDed together. Both describe the same function; which is shorter depends on whether the ones or the zeros happen to form the tidier rectangles, so the solver offers both and you take the smaller.

Is the answer the solver gives really the minimal form?

Yes. The essential prime implicants are taken first, and the rest of the cover is searched exhaustively with branch and bound rather than picked greedily. That matters on a cyclic map - one where no group is essential - because a greedy choice can land on a cover that is one term longer than the shortest, and it would never tell you. Dominated rows and columns are struck out alongside the essentials, over and over until the chart stops shrinking, so most maps never reach the search at all - which is what keeps an exact answer instant even at six variables.

Why are the columns labelled 00, 01, 11, 10 instead of 00, 01, 10, 11?

Because that order is what makes the map work. The labels run in Gray code, where consecutive values differ in exactly one bit, so any two neighbouring cells differ in exactly one variable - and a rectangle of equal values is therefore a term with that variable dropped. In plain binary order, 01 and 10 would sit side by side while differing in two bits, and grouping them would mean nothing. The edges wrap for the same reason: the first and last columns also differ in one bit, so a group may run off one side and continue on the other.

Can I mark cells as don't care?

Not directly: the solver maps an expression, and an expression is true or false in every row - there is no third value to type. Where a function genuinely ignores an input, write that into the formula and the map will show it: a term like (D | !D) puts D on the map as a variable the function does not depend on, which is how the ready-made map for a valid BCD digit is built.

See all questions