Karnaugh Map Simplifier for Boolean Expressions

Enter a 2-, 3-, or 4-variable Boolean expression—or its minterms—to build an interactive Gray-code K-map. Add optional don't-cares, inspect exact groups, and compare minimal SOP and POS forms. Everything runs privately in your browser.

Define the Boolean function

Use the selected variables only. Adjacency means AND, so A'B means ¬A ∧ B.

These cells appear as X and may be used only when they simplify a group.

Private by design: your expression and cell choices stay on this device. They are not uploaded, saved, or added to the page URL.

K-map and simplified forms

The example expression is ready.

Your interactive Karnaugh map will appear here.
Select Build and simplify or press Ctrl/⌘ + Enter.

Advertisement

Boolean expression and minterm syntax

OperationAccepted inputExample
NOT!A, ~A, ¬A, A', not AA'B
ANDAdjacency, &, *, ·, , andAB
OR+, |, , orA + B
XOR^, , xorA xor B
Grouping( )A(B + C)

Operator precedence is NOT, AND, XOR, then OR. Constants 0 and 1 are accepted. For minterms, A is the most significant bit: with four variables, index 10 is A B C D = 1 0 1 0. Both 9-12 and 9–12 are valid ranges.

How the Karnaugh map simplification works

1. Build the truth values

The expression parser evaluates all 2n assignments, or the entered minterms directly mark the 1 cells. Don't-cares replace either value with X.

2. Arrange cells in Gray code

Rows and columns use 0, 1 or 00, 01, 11, 10 order. Adjacent cells—including cells across opposite edges—differ in exactly one bit.

3. Enumerate valid groups

The tool considers every rectangular implicant represented by a fixed/don't-care bit pattern. A valid SOP group covers 1s and optional Xs but no 0s; POS reverses 1 and 0.

4. Select an exact cover

Prime implicants are compared exhaustively. The chosen cover minimizes the number of terms first, then the total number of literals, with deterministic tie-breaking.

Grouping rules: groups contain a power-of-two number of cells, may overlap, and may wrap around map edges. Every required 1 must be covered for SOP, while every required 0 must be covered for POS. X cells are optional and are used only if helpful. These conventions follow the University of Maryland K-map grouping rules and Sonoma State University’s explanation of Gray-code adjacency and don't-cares.

Scope: K-maps are clearest for small functions, so this page intentionally supports 2–4 variables. It returns minimum two-level SOP and POS covers. It does not optimize a factored, XOR-heavy, NAND-only, or technology-specific physical circuit, and another equally minimal cover may exist.

Editorial review: Gray-code placement, minterm indexing, implicant rules, don't-care handling, and representative SOP/POS results checked by the Starlight Tools editorial team. Last reviewed: .

Worked Karnaugh map examples

A group removes changing variables

For F(A,B,C) = Σm(4,5,6,7), all four cells have A = 1 while B and C vary. One four-cell group therefore simplifies to F = A.

Opposite edges are adjacent

In Gray-code order, columns 00 and 10 sit at opposite ends but differ in one bit. A group can wrap from the left edge to the right edge; the border is not a logical break.

Use a don't-care only when useful

For F(A,B,C) = Σm(1,3,7), d(5), the X at 5 completes a four-cell group across all rows where C = 1. The minimal result is F = C. Without that don't-care, more literals are required.

SOP and POS group different cells

SOP groups 1 cells to produce product terms joined by OR. POS groups 0 cells to produce sum factors joined by AND. Either form represents the same specified function.

Karnaugh map simplifier FAQ

What is a Karnaugh map?

A Karnaugh map, or K-map, rearranges a truth table into a Gray-code grid. Because adjacent cells differ in one variable, grouping adjacent 1s or 0s shows which variables can be removed from a Boolean term.

How do I enter a Boolean expression?

Use A, B, C, and D with familiar logic symbols. NOT may be !, ~, ¬, or a trailing apostrophe; adjacency means AND; + means OR; and ^ means XOR. Parentheses override precedence.

What does a minterm number mean?

It is the decimal value of an input assignment read as binary, with A as the most significant bit. In a four-variable map, minterm 10 is binary 1010, so A = 1, B = 0, C = 1, and D = 0.

How should I use don't-care cells?

Enter an X only for an input combination whose output genuinely does not matter. The simplifier can include that X in an SOP or POS group if it creates a smaller expression, but it does not have to cover it.

Can groups wrap around or overlap?

Yes. Opposite edges are adjacent, so groups can wrap horizontally, vertically, or around all four corners. Groups may overlap when that is required for a minimum cover.

Why are the row and column labels not in binary order?

They use Gray-code order: 00, 01, 11, 10. Each neighboring pair differs in one bit, including the first and last labels, which preserves K-map adjacency.

Is the expression guaranteed to be minimal?

Within the supported 2–4 variables, the tool selects an exact two-level cover with the fewest terms and then the fewest literals. Different expressions can tie at that score, and a technology-specific circuit may benefit from factoring or XOR gates.

Does the tool store my Boolean function?

No. The parser, exact-cover calculation, interactive cell changes, copying, and CSV export all operate locally in the browser.

Explore more tools