Skip to content
K-Map Solver

2-Variable Karnaugh Map Solver

A two-variable K-map has just four cells, which makes it the easiest place to learn grouping. Fill it in below to get the simplest sum-of-products or product-of-sums expression.

Try an example
Variables
AB0101

F = Σm(0, 1, 3)

Unsimplified (SOP): F = A'B' + A'B + AB

0false1trueXdon't care (either)

Click a cell to cycle 0 → 1 → X, or hold the button and drag to paint. With the keyboard: arrow keys move, 0 1 X set a value, Space cycles, Page Up/Down switches layers, Ctrl+Z undoes.

Variable namesA B

1–3 characters, starting with a letter. Names must be different from each other.

Simplified K-map result

Updates as you edit. Hover a term or a card to see its group on the map.

AB0101

Simplified Boolean expression

F =A'+B

2 terms2 literals2 gates

Groups

  • A'Essential
    Minterms
    (0, 1)
    Original
    A'B' + A'B
    Simplified
    A'
  • BEssential
    Minterms
    (1, 3)
    Original
    A'B + AB
    Simplified
    B

Truth table check

4 match0 mismatch

Every input row is evaluated against the simplified expression. A don't-care (X) row may give 0 or 1.

mABYour FResultStatus
00011 Match
10111 Match
21000 Match
31111 Match

Glitch check (static-1 hazards)

None found

Every pair of neighbouring 1-cells shares a group, so a single input change cannot make this two-level circuit glitch.

Step-by-step: how the solver gets there (Quine–McCluskey)

Logic circuit

Fit
ABF
1 OR gate and 1 inverter3 gate inputs2 levels Simulated circuit matches your function

Hover a gate to highlight its group · drag to pan · Ctrl/⌘ + scroll or the buttons to zoom.

Gate list
  • A' = NOT(A)
  • F = OR(A', B)

Export & share

Files always use the light theme so they print cleanly.

Images
Expression as
F = \overline{A} + B

How the 2-variable map is laid out

The map is two rows by two columns. A selects the row and B selects the column, so the four cells are A'B', A'B, AB' and AB. With only one bit per axis the order 0, 1 is already a Gray code.

Every cell touches two others, and the top and bottom rows (and the left and right columns) are neighbours too. Each pair of neighbours differs in exactly one variable.

Grouping rules

Groups are rectangles of 1, 2 or 4 cells. A pair of neighbouring ones removes one variable and leaves a single literal; all four cells make the constant 1. Always use the biggest groups you can, and as few as possible.

Two-variable functions are a good warm-up: AND, OR, XOR, NAND and implication all fit on one small map, and the same ideas carry straight over to three and four variables.

Worked example: sum of products

Implication (A → B) is true unless A is true and B is false. Its ones sit in a bent L-shape, so two overlapping groups of two cover them.

F = Σm(0, 1, 3)

AB0101

Simplified result

F = A' + B

  • A' — minterms (0, 1)
  • B — minterms (1, 3)

How to use the K-map solver

  1. Choose 2 to 6 variablesPick how many inputs your function has.
  2. Enter your functionClick the map, fill a truth table, type an expression, or list minterms or maxterms.
  3. Mark don't-caresTap a cell to cycle 0, 1 and X.
  4. Switch between SOP and POSSee the answer as a sum of products or a product of sums.
  5. See the groupsColour-coded loops on the map match each term of the answer.
  6. Check and exportView the logic circuit, compare the truth table, then save a PDF or share a link.

Key features

  • 2 to 6 variables

    Up to 64 cells, with layered maps for 5 and 6 variables.

  • Five ways to enter a function

    Map, truth table, expression, minterm list or maxterm list — switch freely.

  • Provably minimal

    Exact cover search over all prime implicants, with every equally good alternative on offer.

  • Don't-care aware

    X cells enlarge groups but never have to be covered.

  • Wrap-around groups

    Groups across the map edges are drawn as open brackets, the way textbooks show them.

  • Logic circuit

    AND–OR, OR–AND, NAND-only or NOR-only schematics with zoom and gate counts.

  • Self-checking

    Every answer is re-evaluated against your input; a truth table flags any mismatch.

  • Step-by-step

    Quine–McCluskey tables, the prime-implicant chart and Petrick's method.

  • Export and share

    PDF report, PNG/SVG, LaTeX, Verilog, VHDL, C, and a link that reopens your problem.

  • Private and offline-friendly

    Everything runs in your browser. Nothing you enter is uploaded.

Frequently asked questions

How many cells does a 2-variable K-map have?

Four, one per combination of A and B.

Is a K-map worth using for only two variables?

For two variables you can often simplify by eye, but the map is the best way to learn how grouping works before moving on to three, four or more variables.

How do I get the product-of-sums answer?

Switch the result from SOP to POS. The solver then groups the zeros instead of the ones.