A lightweight Karnaugh map solver implemented in pure HTML5, CSS3, and minimal JavaScript. This tool helps simplify Boolean algebraic expressions using the K-map method, always providing results in Sum of Products (SOP) format.
A Karnaugh map (K-map) is a method to simplify Boolean algebra expressions. It provides a visual way to minimize Boolean functions to their simplest form, which is essential in digital logic design and circuit optimization. The map arranges Boolean variables in a grid where adjacent cells differ by only one bit (Gray code order).
The K-map supports 2-4 variables, which can be selected via the variable selector:
- 2 variables: A, B (2×2 grid)
- 3 variables: A, B, C (2×4 grid)
- 4 variables: A, B, C, D (4×4 grid)
Variables are arranged in Gray code order (where adjacent values differ by only one bit).
Variable notation in solutions:
- Regular letter (A): Variable is 1 (TRUE)
- Letter with prime (A'): Variable is 0 (FALSE)
- Example: A'BC'D = A=0, B=1, C=0, D=1
- Interactive K-Map interface with variable selection (2-4 variables)
- Two layout options:
- Gray code layout (optimal for adjacency)
- Normal binary layout (available for 3-4 variables)
- Visual cell grouping with wraparound support
- Auto-solving with Boolean algebra simplification
- Results always in minimal SOP (Sum of Products) format
- Support for don't care conditions (X)
- Multiple solution display when available
- One-click copy solution to clipboard
- Synchronized Truth Table view
- Enhanced info guide with usage examples
- Modern, clean UI with:
- Vector icons
- Organized action bar for controls
- Light/Dark/Auto theme support
- System theme detection
- Quick operations:
- Set all cells to 1
- Set all cells to 0
- Clear the map
- Copy solution
- Triple-state cells:
- 0 (false)
- 1 (true)
- X (don't care)
- Responsive design for mobile and desktop
- Offline support:
- Works without internet after first visit
- Fast loading with cached resources
- Select the number of variables (2-4) using the variable selector
- Click on cells to cycle through values:
- 0 → 1 → X (don't care) → 0
- The solution updates automatically in SOP format
- Click the copy icon to copy the result
- Use "All 1" or "All 0" buttons for quick setup
- Use "Clear" to reset the map
- Switch between K-map and Truth Table views
- Use the layout toggle to switch between Gray code and normal layouts (3-4 variables only)
- Click the info icon for the usage guide
- Built with vanilla HTML5, CSS3, and JavaScript
- No external dependencies
- Boolean algebra simplification using Quine-McCluskey algorithm
- Gray code implementation for optimal cell adjacency
- Real-time synchronization between K-map and Truth Table
- Vector-based UI elements for crisp display
- Responsive layout with CSS Grid and Flexbox
- Mobile-first design principles
- Theme system:
- Light and Dark themes with Auto detection
- CSS variables for consistent styling
- Persistent theme preferences
- Optimized for readability across all K-map sizes
The solver uses the following process:
- Identifies prime implicants using the Quine-McCluskey algorithm
- Finds essential prime implicants
- Solves the covering problem for remaining implicants
- Simplifies the expression using Boolean algebra
- Presents the result in minimal SOP format
- Try to get it working on browsers as old as Chrome 104+, Safari 12+. Compare working features here
Created by robonxt.
Assisted by Claude Sonnet 3.5 in Windsurf IDE.
Logic inspired by https://github.com/obsfx/kmap-solver-lib
Icon generated by Perchance