Free Boolean logic minimizer · 2–6 variables

Karnaugh Map Solver — Simplify Boolean Expressions Online

Use this interactive Karnaugh map solver to minimize Boolean functions into sum-of-products (SOP) and product-of-sums (POS) forms. Build a K-map by clicking cells, enter minterms or maxterms, paste a truth table, or type a Boolean expression. Include don't-care conditions, inspect prime implicants, and see each selected group highlighted in Gray-code maps for two to six variables.
◈ 2–6 Boolean variables•Σm / ΠM / truth table / expression•SOP + POS minimization•Prime implicants & groups•Copy, export & share

Interactive Karnaugh Map Calculator

Map-cell edits recalculate immediately; submit minterm lists, imported tables or expressions with their action buttons.

Use one distinct letter per variable, separated by commas or spaces. The first name is the most significant bit (MSB).

Build the function directly on the map

Select any cell to cycle it through 0 → 1 → X → 0. X means don't-care. For five and six variables, use the linked map layers to represent the additional variable combinations.

K-map visualization
Gray-code order · wrap-around adjacency · linked layers for 5–6 variables · use arrow keys to move between cells
1 — true 0 — false X — don't-careColored dots = selected groups

Minimized Boolean expressions

The solver searches first for fewer terms, then fewer literals. Any search-limit warning is reported in the minimization analysis.

Minimal sum of products (SOP)

B' + C'D'

Minimal product of sums (POS)

(…)
7On-set minterms
5Don't-cares
2Selected groups
3Selected literals
Selected implicant groupsChoose a group to highlight its cells.
Logic circuit structure

This structural diagram shows how the minimized expression maps to two-level logic gates. It is a conceptual gate arrangement, not a timing or electrical simulation.

Step-by-step minimization and prime implicants
Canonical forms and complete truth table
Canonical sum of minterms
Canonical product of maxterms
Truth table

What is a Karnaugh map (K-map)?

A Karnaugh map, often shortened to K-map, is a visual method for simplifying Boolean algebra expressions. It arranges the possible input combinations of a digital logic function into a grid so that adjacent cells differ in exactly one input variable. By grouping adjacent 1s or 0s, you can remove variables that change inside a group and produce a shorter logic expression.

This online Karnaugh map solver automates the grouping and minimization process. It supports two to six variables, don't-care conditions, sum-of-products and product-of-sums outputs, editable truth tables, minterm and maxterm lists, and Boolean expression input. The map remains interactive, so a cell change updates the minimized result and its group visualization.

Quick definition: A K-map is a Gray-code-ordered truth table used to find adjacent groups of 1s (for SOP) or 0s (for POS). Each group becomes a simpler Boolean term by eliminating variables that change within that group.

How to use this Karnaugh map solver

  1. Choose the variable count. Select 2, 3, 4, 5 or 6 variables. The first variable is the most significant bit in each minterm index.
  2. Set variable names if needed. Use distinct single-letter names, such as A, B, C and D, or X, Y, Z and W.
  3. Enter your function. Click cells in the map, enter a minterm/maxterm list, edit the truth table, or paste a supported Boolean expression.
  4. Add don't-cares when appropriate. Mark input combinations that are impossible or unspecified as X. The solver can use them to form larger groups.
  5. Compare SOP and POS. SOP groups the 1-cells. POS groups the 0-cells. Switch the map view to inspect the groups used by each result.
  6. Review and export. Select any group to highlight its cells, inspect the prime-implicant table and circuit structure, then copy or download the result.

SOP vs. POS: which form should you use?

Sum of products (SOP) is an OR of product terms. Each product term is an AND of literals, for example A'B + CD. In a K-map, SOP simplification groups the cells where the function is 1. The literals that remain constant inside each group form one product term.

Product of sums (POS) is an AND of sum clauses, for example (A + B')(C + D). POS simplification groups the cells where the function is 0. Each zero-group produces a sum clause that evaluates to 0 for the assignments inside that group.

Practical comparison: Neither form is always shorter. Compare the term count and literal count, then consider the gate family available in your design (AND–OR for SOP or OR–AND for POS). A real implementation may also favor NAND-only or NOR-only logic.

Gray code and K-map cell order

K-map rows and columns use Gray-code order, usually 00, 01, 11, 10 for a two-bit axis. Unlike ordinary binary order, consecutive Gray-code labels differ in only one bit. This is what makes horizontal and vertical neighbors represent input combinations that differ in exactly one variable.

The first and last rows are also adjacent, as are the first and last columns. For that reason, corner cells can belong to the same group even though they do not touch in an ordinary rectangular drawing. The solver uses Gray-code ordering for its maps and allows minimization groups to wrap around the edges.

Karnaugh map grouping rules

  • Use powers of two. A valid group contains 1, 2, 4, 8, 16 or another power-of-two number of cells.
  • Make groups as large as possible. Larger groups eliminate more changing variables and generally produce simpler terms.
  • Cover every required cell. Each 1 must be covered at least once for SOP; each 0 must be covered at least once for POS.
  • Overlap is allowed. A cell can be included in more than one group when that helps obtain a smaller expression.
  • Wrap at map edges. Opposite edges are adjacent because the map represents a cyclic Gray-code arrangement.
  • Do not group the wrong value. An SOP group may contain 1s and selected don't-cares, not required 0s. A POS group may contain 0s and selected don't-cares, not required 1s.
  • Don't-cares are optional. Include an X only when it helps simplify the function. A group made entirely of X cells is not needed.

Don't-care conditions in Boolean minimization

A don't-care condition represents an input combination for which the output is irrelevant, unreachable or not specified by the design. It is marked X in a K-map. During minimization, an X may be treated as 0 or 1 depending on which choice creates a more useful group.

For example, a BCD input uses only decimal digits 0 through 9. The six four-bit combinations from 10 through 15 are not valid BCD digits, so a particular BCD-driven output may treat those combinations as don't-cares. Whether that is safe depends on the actual circuit specification; never mark a reachable, meaningful input as a don't-care merely to force a shorter expression.

Five- and six-variable Karnaugh maps

A five-variable function has 32 possible input combinations. It is commonly drawn as two four-variable maps: one for the extra variable equal to 0 and one for it equal to 1. Corresponding cells in the two maps are adjacent, so a group can extend from one map to the other.

A six-variable function has 64 combinations. This solver displays it as four linked 4×4 maps, one for each Gray-code combination of the two leading variables. A selected implicant can therefore appear in more than one map slice. The exact minimizer uses the Boolean assignments, not visual proximity alone, so cross-layer adjacency is handled consistently.

How the solver minimizes a Boolean function

The tool uses a tabular Boolean minimization process based on the Quine–McCluskey method. It begins with the required minterms and any don't-care minterms. Terms that differ in one bit are combined by replacing that bit with a dash. Repeated combination produces prime implicants: groups that cannot be expanded further without covering an excluded combination.

Next, the solver builds a prime-implicant chart showing which implicants cover each required minterm. An essential prime implicant is the only prime implicant that covers at least one required minterm, so it must be included. A cover search then chooses a set of implicants that covers every required minterm, preferring fewer terms and then fewer literals. POS is obtained by applying the same process to the function's zero-set and converting the resulting implicants into sum clauses.

Scope note: The K-map display is intended for small Boolean functions with two to six variables. The tabular method is more systematic than visual grouping for this range, but it does not replace technology-aware logic synthesis, hazard analysis, timing analysis or physical gate optimization.

Worked Karnaugh map examples

Example 1: a three-variable function

Consider F(A,B,C) = Σm(1,3,5,7). These are the four combinations where C = 1. They form one group of four in the three-variable K-map. A and B change within the group and disappear, leaving:

F(A,B,C) = C

Example 2: a four-variable function with don't-cares

Consider F(A,B,C,D) = Σm(0,1,4,8,10,11,12) + d(2,3,6,9,15). The don't-care entries can be used to complete larger groups. One minimal SOP is:

F = B' + C'D'

In this example, the group for B' covers the required 1s at which B is 0, using suitable don't-care cells to complete the eight-cell region. The second group covers the remaining required minterms with C' and D'. Equivalent minimal covers can sometimes be expressed differently.

Prime implicants and essential prime implicants

An implicant is a product term that never evaluates to 1 where the function is required to be 0. A prime implicant is an implicant that cannot be made more general by removing another literal. A prime implicant is essential when it uniquely covers at least one required minterm.

Prime implicants are the candidate groups from which a minimized expression is selected. Not every prime implicant must appear in the final expression. The tool lists the candidates, marks essential terms, and identifies the selected cover so you can trace how the final SOP or POS expression was formed.

Boolean expression input syntax

Use the expression tab to evaluate a Boolean function and populate the map. The parser accepts single-letter variable names matching the active variable list. It supports postfix apostrophe and prefix NOT, explicit or implicit AND, OR, XOR, parentheses, and the constants 0 and 1.

OperationAccepted formsExample
NOTA', !A, ~A, ¬AA'B
ANDAdjacency, *, ·, ., &A*B
OR+, |A+B
XOR^, ⊕A^B
Grouping / constants( ), 0, 1(A+B')C

Where Karnaugh maps are used

K-maps are taught in digital logic and used to reason about small combinational logic functions. They can help students and designers simplify decoder outputs, control conditions, arithmetic flags, multiplexing logic and small finite-state-machine output functions. The simplified Boolean expression can then be translated into AND, OR, NAND, NOR or other supported gate structures.

For larger functions, multi-output optimization or implementation-specific constraints, designers generally move to automated logic synthesis and Boolean optimization tools. A minimized two-level SOP or POS expression is a useful logical result, but it is not automatically the fastest, smallest or lowest-power physical implementation in every technology.

Limitations and common mistakes

  • Variable order matters for indexing. This tool treats the first listed variable as the most significant bit. Reordering variables changes the minterm numbers associated with the same named assignment.
  • Do not confuse Gray code with binary order. The K-map axes use 00, 01, 11, 10 so adjacent cells differ in one bit.
  • Don't-care cells are not required outputs. They can be used to enlarge a group but do not need to appear in a final cover.
  • Diagonal cells are not adjacent. Only horizontal, vertical, wrap-around and valid cross-layer neighbors are adjacent.
  • Equivalent answers may differ. More than one minimal cover can exist for a function. Compare the truth table, not only the visual arrangement.
  • A logic-gate diagram is structural. It shows the two-level gate interpretation of the selected expression; it does not model physical delay, fan-out or hazard behavior.

Frequently asked questions

What is a Karnaugh map solver?

A Karnaugh map solver simplifies a Boolean function by grouping adjacent 1s for SOP or adjacent 0s for POS. This tool supports two to six variables and accepts map cells, minterms, maxterms, truth tables and Boolean expressions.

What is the difference between SOP and POS?

SOP is an OR of AND terms and is found by grouping 1-cells. POS is an AND of OR clauses and is found by grouping 0-cells. Both represent the same function when derived correctly.

How many variables does this K-map calculator support?

It supports two through six variables. Five variables are shown as two linked four-variable maps; six variables are shown as four linked maps.

What does X mean in a Karnaugh map?

X is a don't-care condition. It can be treated as either 0 or 1 when that helps form a larger group, but it does not have to be included in a group.

Can K-map groups wrap around the edges?

Yes. The first and last rows are adjacent, and the first and last columns are adjacent. For five or six variables, corresponding cells in different map slices can also be adjacent.

Can two groups overlap?

Yes. Groups may overlap when doing so lets the final expression cover all required cells using fewer terms or literals.

Why must K-map groups contain powers of two?

Each group removes a whole set of changing variables. Groups of 1, 2, 4, 8 or 16 cells correspond to one, two, three, four or more varying input bits.

What is an essential prime implicant?

It is a prime implicant that covers at least one required minterm not covered by any other prime implicant. Every valid minimum cover must include it.

Does the solver simplify expressions with XOR?

Yes. The expression parser evaluates XOR with ^ or ⊕ and converts the resulting truth table into minimized SOP and POS forms. The final forms are standard two-level Boolean expressions and may not preserve XOR notation.

Why can two textbooks show different simplified answers?

A function may have multiple equally minimal group covers. Variable ordering, notation and the selected prime implicants can make the written expressions look different even when their truth tables are identical.

Can I use this for circuit design?

You can use the minimized expressions as a starting point for a small combinational logic design. For a finished circuit, also verify electrical constraints, propagation delay, fan-out, hazards, gate availability and implementation-specific optimization.

Can I export or share my K-map?

Yes. Copy the expressions, download the solution as text, download the truth table as CSV, print the page or generate a shareable URL that encodes the current variable names and cell values.

References and further reading

Scroll to Top