Classic code-breaking logic game

Crack the Mastermind Code

Guess the hidden color sequence and use black and white peg clues to zero in on the exact code before you run out of guesses.

Pick colors below to fill your first guess.

Black & white pegs

Black means right color, right spot. White means right color, wrong spot. No peg means the color isn't there.

Fully configurable

Choose code length, palette size and guess limit before every new game to change the difficulty.

🔒

Reveal on finish

Win or lose, the secret sequence is revealed at the end so you can see exactly what it was.

How to play Mastermind

The computer secretly picks a sequence of colored pegs. Your job is to guess the exact sequence within a limited number of tries, using feedback after each guess.

  1. Fill a guessClick colors from the palette to fill each peg slot in the current row, in order.
  2. Submit and read the cluesSubmit your guess to get black pegs for correct color-and-position matches and white pegs for correct colors in the wrong position.
  3. Narrow it downUse the clues from every row to refine your next guess until you find the exact code or run out of guesses.

About Mastermind

Mastermind is a deduction game that rewards careful tracking more than luck. Since peg colors in the feedback don't say which position they refer to, working out the code is a puzzle of elimination — testing colors, then testing positions, then refining as the guess count shrinks.

Colors can repeat

The hidden code may reuse a color more than once, so don't assume all pegs are unique colors.

Test broadly first

Early guesses that spread out colors evenly reveal which colors are even in play before you worry about position.

Difficulty is adjustable

More colors and a longer code make the puzzle exponentially harder — start small if you're new to it.

A game of pure logic

There's no hidden randomness after the code is set — every clue is exact, so careful notes beat guesswork.

Mastermind FAQ

Common questions about pegs, repeats and strategy.

What do the black and white pegs mean?

A black peg means one of your guessed colors is the correct color in the correct position. A white peg means a guessed color exists in the code but in a different position. Peg colors give no clue about which slot they refer to.

Can colors repeat in the secret code?

Yes. The hidden code can use the same color more than once, just like the classic board game, which is part of what makes deduction tricky.

How many guesses do I get?

By default you get 10 guesses, though you can change the code length and color count before starting a new game, which affects how hard the puzzle is.

What happens if I run out of guesses?

The game reveals the secret code so you can see what it was, and you can start a fresh game with a new hidden code at any time.

Is there a strategy to solving it faster?

A common approach is to first find which colors appear at all using simple test guesses, then use black-peg feedback to narrow down positions. Tracking previous guesses carefully is more effective than guessing randomly.