Looking for a quick Nim game online? Nim on My MP Games is the classic take-away strategy game of piles and pure logic, ready to play in your browser. Four piles hold 1, 3, 5 and 7 objects. Take turns removing objects from one pile, and whoever takes the very last object wins. Invite a friend with a room code, share one phone or laptop, or practise against the computer. It is free, it works on desktop, tablet and mobile, and there is no download, no app and no sign-up.
How to Play the Nim Game Online
- Pick a mode. Press Create room to host a friend, Join room if you have a code, Local vs to share one device, or Play vs Computer for an instant solo game.
- Choose a pile. On your turn, look at the four piles and decide which one to take from. You can only take from one pile per move.
- Take objects. Press Take 1, Take 2 or Take 3 under that pile. When a pile has more than three objects, a Take all button lets you clear it in one go.
- Take the last one. The game goes back and forth until the piles are empty. The player who removes the final object wins.
- Play again. The Moves list shows every take in order, so you can review the game, then press Restart match for another round.
Nim Rules
The piles
Classic Nim here starts with four piles of 1, 3, 5 and 7 objects, sixteen in total. This is the same famous layout people search for as "Nim 1 3 5 7".
Taking turns
Players alternate. On each turn you must take at least one object, and every object you take must come from a single pile. You cannot pass and you cannot split a pile.
Winning
The stage reminds you of the rule: last take wins. There are no draws in Nim, because someone always takes the final object.
Game Modes: Online, Local and vs Computer
Online with friends (room code)
Press Create room and you get a five-character room code. Copy the code or the invite link and send it to your friend. They enter it under Join room or open the link, you approve them, both of you press Ready and the host starts the match. Hosts can lock the room, auto-approve joiners and set spectating to public or private, and there is a room chat for some friendly trash talk.
Challenge online players
Open the live arena, see who is online right now and send a duel invite. No login is needed.
Local vs on one device
Want a Nim game 2 player style on one device? Two players share one screen and take turns, with the current player's name shown above the piles. It is ideal for a classroom, a sofa or a maths club.
Play vs Computer
Press Play vs Computer and the piles appear straight away with you to move first. The computer replies instantly, which makes it a handy way to test the strategies below.
Controls for Touch, Mouse and Keyboard
- Touch: tap the Take button under the pile you want. The piles and buttons fit a phone screen in portrait.
- Mouse: click any Take button. Only legal moves are shown, so you can never take more than a pile holds.
- Keyboard: press Tab to move between the Take buttons and Enter to make your move.
Tips and Strategy: How to Win Nim
- Know the 1-3-5-7 secret. From the starting position, the player who moves second can always win with perfect play. If you go first, aim to set small traps and wait for a mistake.
- Make the piles pair up. Two equal piles cancel each other out. If you leave your opponent two equal piles, copy every move they make on the other pile and you will take the last object.
- Count piles the way this version plays. Because each move takes 1, 2 or 3 objects or the whole pile, a pile of 5 behaves like a pile of 1, a pile of 6 like 2 and a pile of 7 like 3. Leave positions where these values pair off and you are in control.
- Never leave one big pile alone. If only one pile is left with objects in it, the player to move just takes all and wins.
- Watch the endgame. With two small piles left, make them equal; with one object left in two piles, it is already decided.
History and Variants of Nim
Games of taking stones or sticks from piles are very old and appear in many cultures. The name Nim was given by Harvard mathematician Charles L. Bouton, who published a complete mathematical theory of the game in 1901. His winning method, based on binary arithmetic, turned Nim into the starting point of combinatorial game theory and the later Sprague-Grundy theorem.
Nim also helped launch computer gaming. The Nimatron machine played visitors at the 1940 New York World's Fair, and the Nimrod computer challenged the public at the 1951 Festival of Britain. The 1–3–5–7 layout later became famous as the "Marienbad" game from the 1961 film Last Year at Marienbad.
The best-known twist is Misère Nim, where the player who takes the last object loses. You can try it from the Variants list on this page, along with other take-away and counting games such as Kayles, Wythoff's Game and 21 Flags. If you would rather sow seeds than take them, try Mancala online 2 player. Once you have learned the classic Nim game online here, switch to Misère and see how much your strategy has to change.

Nim Game FAQ
Can you play the Nim game online with a friend?
Yes. Press Create room to get a five-character room code, then send the code or the invite link to your friend. They join from their own phone, tablet or computer, you approve them, and the match starts. You can also challenge whoever is online in the live arena.
Can 2 players play Nim on one device?
Yes. Choose Local vs and two players share the same screen, taking turns. The name of the player whose turn it is appears above the piles.
Is this Nim game free?
Yes. Nim on My MP Games is completely free, with no download, no app and no sign-up needed. It runs in any modern browser on desktop, tablet and mobile, alongside 50+ other free games.
What are the rules of Nim?
Players take turns removing objects from piles. Each turn you take at least one object, all from the same pile. In the classic version here the piles start at 1, 3, 5 and 7, you can take 1, 2, 3 or the whole pile, and whoever takes the last object wins.
How do you win Nim 1 3 5 7?
The 1-3-5-7 start is a losing position for the player who moves first, so with perfect play the second player wins. The key is to keep handing your opponent balanced positions, such as two equal piles, and then mirror every move they make.
How do you win Nim if you go first?
Against a perfect opponent you cannot force a win from 1-3-5-7 when moving first. Against real players, keep the position complicated, avoid leaving equal pairs for your opponent, and pounce as soon as they leave you a chance to balance the piles.
Can you play Nim against the computer?
Yes. Press Play vs Computer and the game starts straight away with you moving first. The computer replies instantly, so it is a quick way to practise the pairing strategy.
What is Misère Nim?
Misère Nim flips the goal: the player who takes the last object loses. Pick Misère Nim from the Variants list on the Nim page to play it. The strategy is almost the same until the very end, when you must leave your opponent the last object instead of taking it.
More Free 2 Player Games
Nim is one of 50+ free games on My MP Games. Try these related games next: