Projects › Games › Sudoku
Play sudoku free online
You can play sudoku free right here: pick Easy, Medium, Hard or Expert and a brand new puzzle is made for you, with exactly one answer. Tap a square, then a number. Add pencil notes, undo, get a hint when you're stuck, and print any puzzle with its answer. Your game saves itself, so you can come back to it later. No sign-up and no download. Then build your own sudoku game with a free AI assistant.
Medium sudoku
Medium · 0:00Every puzzle is made in this browser and has exactly one answer. Your game is saved on this device only.
The rules, and how to get started
Fill the grid so that every row, every column and every 3 × 3 box has each number from 1 to 9 exactly once. The numbers already there can't be changed. There's no maths involved: the numbers could just as well be letters or colours.
- Look for the easy ones first. Pick a number, say 1, and look at each box. If the 1s in nearby rows and columns block every square but one, the 1 must go there.
- Check what's missing. If a row, column or box has eight numbers, the last square is whatever's left.
- Use notes on harder puzzles. Switch on Notes and write the small numbers each square could be. When you place a number, it's rubbed out of the notes around it for you.
- Tap a number to see where it is. Every matching number lights up, so you can see which rows and boxes still need it. The little count under each key shows how many are left to place.
The levels: Easy and Medium can be solved by finding one square at a time. Hard needs a trick or two, such as spotting a pair of squares that must hold the same two numbers. Expert has the fewest numbers to start with and needs notes and patience.
Your own sudoku game
You'll describe it to a free AI assistant, paste what it writes into a file, and open it in your browser. No coding needed. The clever part is making new puzzles that have only one answer, and the AI can do that for you if you ask in the right way.
Build it in five steps
Step 1 gives you a simple version that works, and each step after it adds more. Yours will look a bit different from the one above, because the AI writes its own version each time.
Ask for a playable grid
Start with one ready-made puzzle, so you can check the grid and the typing work. Copy this prompt into your AI assistant:
Copy this promptI don't know how to code. Please make me a sudoku game that runs in a web browser. Requirements: - ONE single HTML file (HTML, CSS and JavaScript together), no external libraries, no internet needed. I will save it and double-click it. - A 9 by 9 grid with thicker lines around each 3 by 3 box, big enough to play on a phone. - Start with one real sudoku puzzle written into the code. Its numbers are bold and can't be changed. - Tap or click a square to select it, then tap a number from 1 to 9 on buttons under the grid. Typing a number on the keyboard works too, and Backspace clears a square. - Light up the selected square's row, column and box, and every other square with the same number. - When the grid is full and correct, show "Solved!". Please give me the complete file in one code block, then tell me in simple steps how to save and open it.
Copy the code, paste it into your text editor and save it as sudoku.html. Double-click it and fill in a few squares.
Make new puzzles
This is the clever bit: a puzzle generator that always makes puzzles with exactly one answer.
Copy this promptThat works, thank you. Now please make new puzzles instead of the fixed one: - Write a solver that fills the grid with backtracking (try a number, move on, go back if it gets stuck). - To make a puzzle: fill an empty grid using the solver with the numbers tried in a random order, so you get a random finished grid. Keep that as the answer. - Then take numbers away one at a time in a random order. After each one, count the solutions (stop counting at 2). If there's more than one solution, put the number back. - Add a "New puzzle" button. Send me the complete updated file.
Always ask for the complete file. Replace everything in sudoku.html, save, and refresh the tab (F5 or Cmd+R).Add difficulty levels
Fewer numbers isn't the whole story. A puzzle is harder when it needs harder tricks, so ask the AI to check how a person would solve it.
Copy this promptPlease add Easy, Medium, Hard and Expert buttons. - Write a second solver that only uses the tricks a person would: "naked singles" (a square with only one possible number), "hidden singles" (a number with only one place in a row, column or box), then "pointing pairs" and "naked pairs". It reports the hardest trick it needed, or that it got stuck. - Easy: stop taking numbers away at about 38 left, and only take one away if singles can still solve it. - Medium: the same, down to about 30. - Hard: down to about 26, allowing pairs, and the puzzle must need at least one pair. - Expert: take away as many as possible, and the puzzle must get the human solver stuck. - Take numbers away in matching pairs from opposite sides of the grid, so the puzzles look neat. - If a puzzle doesn't meet its level, make another one. Send me the complete updated file.
If Expert takes a long time to appear, ask the AI to "give up after 1.5 seconds and use the hardest puzzle made so far".Add notes, undo and hints
These turn it from a demo into something you'd really play.
Copy this promptPlease add: - A "Notes" switch. When it's on, tapping a number writes it small in the corner of the square instead (up to 9 small numbers in a 3 by 3 layout). Placing a real number rubs that number out of the notes in the same row, column and box. - An "Undo" button that goes back one move at a time, and an "Erase" button. - A "Show mistakes" on/off switch that turns wrong numbers red. - A "Hint" button that fills in the selected square, or the empty square with the fewest possibilities if nothing is selected. - Under each number button, show how many of that number are still to place. Send me the complete updated file.
Add a timer, saving and printing
Finally, make it remember your game and let you print puzzles for later.
Copy this promptPlease add: - A timer that starts with each puzzle, pauses when I switch to another tab, and shows my time when I finish. - Save the game in localStorage after every move, so if I close the page and come back, my puzzle, notes and time are still there. - A "Print" button that prints the puzzle big on one page in black and white, with a "Name: ____" line, and the answer on a second page. Hide everything else on the page when printing. Send me the complete updated file.
Quick fixes
A puzzle has more than one answer
Ask the AI: "After taking each number away, run the solver and count every solution up to 2. Only keep the number out if the count is exactly 1."
New puzzle freezes the page
The solver is probably slow. Ask the AI to "store what each row, column and box already has as bit masks, and always fill the empty square with the fewest options first".
Hard and Easy feel the same
Ask the AI to "grade each puzzle with the human-style solver and print the grade and number of clues to the console", then check the levels really differ.
The phone keyboard pops up when I tap a square
The squares are probably text boxes. Ask the AI to "make the squares plain divs, not inputs, and use the on-screen number buttons on phones".
It opens as text
Re-save as plain text with exactly .html at the end, not .txt.
Questions people ask
Is this sudoku free?
Yes. It's free with no sign-up and no limit on puzzles. Every puzzle is made in your own browser.
Does every puzzle have one answer?
Yes. Each puzzle is checked by a solver as it's made, and a number is only taken away if the puzzle still has exactly one answer.
What's the difference between the levels?
Easy starts with about 38 numbers and Medium with about 30, and both can be solved by finding one square at a time. Hard has about 26 and needs a trick such as a pointing pair. Expert has as few as possible, usually 23 to 25, and needs notes and harder tricks.
Can I play on my phone?
Yes. Tap a square, then tap a number under the grid. It works on phones and tablets as well as computers, and on a keyboard you can use the arrow keys and number keys.
Will it remember my game?
Yes. Your puzzle, notes and time are saved on this device after every move, so you can close the page and carry on later. Nothing is sent to us.
Can I print a sudoku?
Yes. Press Print with answer for the puzzle on one page, with a name line, and the answer on a second page. Pick a level and press New puzzle first to print a fresh one.
Twist it into something else
Daily sudoku
the same puzzle for everyone each day, made from the date
Mini sudoku for kids
a 4 by 4 grid with pictures instead of numbers
Killer sudoku
dotted cages with sums instead of starting numbers
Two-player race
the same puzzle side by side, first to finish wins
Sudoku solver
type in a puzzle from the newspaper and see the answer, one step at a time
Book of puzzles
print 20 puzzles, four to a page, with the answers at the back