🔐 Code breaking logic game · Solo or 2 players

Mastermind Online: Crack the Code

Guess the secret code of four colors. Black pegs mean right color, right spot. White pegs mean right color, wrong spot. Use logic to crack it in as few guesses as you can.

How to play Mastermind

New to Mastermind? Read the full rules and strategy guideHow to read the pegs, a guess by guess worked example and how a solver cracks any code.
1

Build a guess

Tap four colors from the palette under the board. Each color can appear only once in a guess.

2

Check it

Press Check guess. Small pegs next to the row tell you how close you are.

3

Read the pegs

A black peg is a right color in the right spot. A white peg is a right color in the wrong spot.

4

Crack the code

Use every clue to plan your next row. Four black pegs means the code is cracked.

Rules and scoring

The secret code is four different colors picked from six: red, orange, yellow, green, blue and pink. No color appears twice in the code, and your guesses follow the same rule, so every guess uses four different colors. Order matters.

After each guess the board answers with up to four small pegs. A black peg means one of your colors is correct and in the correct hole. A white peg means one of your colors is in the code but sits in a different hole. An empty spot means a color that is not in the code. The pegs never say which hole they belong to. Working that out is the puzzle.

Solo score: every stage starts with a guess limit. When you crack the code, each unused guess is worth 1,000 points, so solving stage 1 in 5 of 12 guesses earns 7,000. Cracking it on your very last guess still earns 500 points. Points add up across the stages into your run total. A hint costs 2,000 points, and your total never drops below zero.

Every peg carries a small symbol, so color blind players can tell the colors apart by shape.

Modes and settings

ModeHow it works
Solo stagesTen stages with 12, 11, 10, 10, 9, 9, 8, 7, 7 and 6 guesses. Run out of guesses and the run starts again at stage 1.
HintOnce per solo stage, reveal one peg of the code in its correct hole. It stays locked in place on every row after that.
Race a friendTwo players, one room. Each player cracks their own code, made by the other player's device.
Guess limitThe host picks 8, 10 or 12 guesses for the race.
WinnerFewer guesses wins. Equal guesses go to the faster player. If neither cracks the code, it is a draw.

Your best stage and best run score are saved on this device.

Mastermind strategy tips

Your first row always tests four of the six colors, so the feedback tells you right away how many of them are in the code. Four pegs of any kind means you know every color and only the order is left. Two pegs means the two colors you left out are both in the code.

Change one thing at a time when you are unsure. Swapping just two pegs shows you exactly what turned a white peg black.

Keep every clue in mind, not just the last one. Before you press Check guess, compare your new row with each earlier row and ask whether it would have produced the same pegs. If not, it cannot be the code. Later stages give you as few as six guesses, so this habit matters more the further you climb.

Save the hint for when you are stuck: it costs 2,000 points, the value of two unused guesses. Want a deeper walk through? Read our Mastermind strategy guide with worked examples.

A fair 2 player race

In Race a friend, both players play at the same time, but each of you cracks a different code. Your friend's device makes your secret code and checks your guesses, and your device does the same for them. Before the race starts, each device locks its code with a cryptographic fingerprint, so nobody can change a code halfway through. When the race ends, both codes are revealed and each device checks the fingerprint and every answer it received. If anything does not match, the honest player gets the win.

Fewer guesses wins. If you both need the same number, the faster player wins. The host's device keeps the time for both players and allows for the connection delay, so a slow connection does not cost you the tie break.

Why play Mastermind online

Mastermind is a quick logic workout. Each round asks you to hold several clues in your head, rule out options and test an idea, the same thinking used in math and coding. A stage takes a few minutes, and it suits kids learning to reason step by step as well as adults who love a puzzle.

Mastermind FAQ

Is this Mastermind game free to play?

Yes. Mastermind on OnlineGames2Play is completely free and runs in your web browser on phones, tablets and computers. There is nothing to download and you do not need an account.

What do the black and white pegs mean?

A black peg means one of your colors is correct and in the correct hole. A white peg means one of your colors is in the code but in a different hole. An empty spot means a color that is not in the code. The pegs do not show which hole they belong to, so you have to work that out from your guesses.

Can a color appear twice in the code?

No. The secret code is always four different colors chosen from six, and every guess must also use four different colors. A color already in your current guess is dimmed on the palette.

How does scoring work in solo stages?

When you crack a code, every guess you did not use is worth 1,000 points. Cracking the code on your last guess still earns 500 points, so a solved stage is never worth zero. Stage scores add up into your run total, and your best stage and best total are saved on this device.

What happens if I run out of guesses?

The secret code is revealed and your run starts again at stage 1. Each stage gives fewer guesses than the one before, from 12 on stage 1 down to 6 on stage 10, so the later stages need careful logic.

How does the hint work?

Once per solo stage you can press Hint to reveal one peg of the code in its correct hole. That peg stays locked in place on your current row and every row after it. A hint costs 2,000 points, which come off when you clear the stage, and your total never drops below zero.

How do I play Mastermind with a friend?

Choose Race a friend, enter your name and press Create a room. Share the six letter room code or the invite link. The host picks 8, 10 or 12 guesses and starts the race. Each player cracks their own code at the same time, and fewer guesses wins.

Can my friend cheat in a 2 player race?

Not without being caught. Your friend's device makes your code and locks it with a cryptographic fingerprint before the race starts. When the race ends, both codes are revealed and your device checks the fingerprint and every answer it received. If anything does not match, you see a clear message and the win goes to you.

Mastermind
Room code
Share this code or the invite link with one friend.

Players

1 of 6 joined
1/10Stage
12Guesses left
0Score
0:00Time

Stage 1 of 10

Code cracked!