free tool, no sign-up
Magic Square Generator
Generate magic square puzzles where rows, columns, and diagonals all sum to the same number. A classic math puzzle that builds addition skills and logical thinking.
What is a Magic Square?
A magic square is a grid of numbers where every row, column, and diagonal adds up to the same "magic sum". Use each number from 1 to 9 exactly once.
Select your options and click
"Generate Magic Square" to create a puzzle
The Magic Square Generator creates number grid puzzles where every row, column, and diagonal adds up to the same 'magic sum.' Use numbers 1 through n² exactly once to complete the grid. For a 3×3 square, use 1-9 and each line sums to 15. For 4×4, use 1-16 summing to 34. Magic squares have fascinated mathematicians for thousands of years and provide excellent practice combining addition skills with logical deduction.
What a magic square asks a child to do
A magic square is a grid filled with the numbers 1 to n squared, used once each, arranged so every row, every column and both long diagonals add up to the same total. That total is the magic sum, and it is fixed by the size of the grid: 15 for a 3x3 using 1 to 9, 34 for a 4x4 using 1 to 16, and 65 for a 5x5 using 1 to 25. The sum is printed on the sheet, so nobody has to guess what they are aiming for.
Some of the numbers are already in place and the rest are blank. To fill a blank, a child adds up what is already in that row or column and subtracts from the magic sum. That is the whole method, repeated: find the line with only one gap, work out what is missing, write it in, and now another line has only one gap. It is mental addition with a reason to be careful, which is why magic square puzzles turn up in maths classrooms far more often than plain sums do.
Choosing a grid size and difficulty
Three grid sizes are available. The 3x3 is the one most people mean by a magic square puzzle: nine cells, numbers 1 to 9, every line summing to 15. It suits roughly ages seven and up, or anyone meeting the idea for the first time. The 4x4 magic square uses 1 to 16 and a sum of 34, which pushes children into two-digit addition and is a good fit for upper primary. The 5x5 runs to 25 and a sum of 65 and is genuinely demanding, better as a challenge sheet or an early-finisher task than as whole-class work.
Difficulty controls how many cells start blank. On a 3x3 that is three blanks on easy, five on medium and six on hard. A 4x4 removes six, nine or eleven, and a 5x5 removes ten, fourteen or seventeen. Each puzzle is then checked to make sure only one arrangement of numbers completes it, and a number is put back if the grid would otherwise have more than one answer. So a hard puzzle occasionally lands with a blank or two fewer than the maximum. That is deliberate: a puzzle with two valid answers is a puzzle a child cannot check.
Printing, solutions and the answer key
Give the puzzle a title in the box at the top, pick one of five colour themes for the grid lines and shaded starting cells, and press Generate Magic Square. Press it again for a completely new grid at the same settings, which is the quickest way to make a set of different sheets for a table of children who would otherwise copy each other.
The Puzzle and Solution tabs above the preview switch between the blank grid and the completed one. Printing follows whichever tab is showing, so a solved grid prints with Answer Key in the heading and the numbers the child was meant to supply shown in green. The puzzle version prints with the magic sum, a line of instructions, and name and date lines at the bottom. Download Image saves the same grid as a PNG at double resolution if you want to drop it into a worksheet, a slide or a newsletter rather than print it directly.
The printed page is centred with generous padding rather than pinned to a fixed paper size, so US Letter and A4 both come out fine without changing anything. If the shaded starting cells come out white, turn on background graphics in your printer dialog; that setting is off by default in most browsers and is the usual reason a printed grid looks flatter than the preview.
Using magic squares in a lesson or at home
A 3x3 easy puzzle takes most children two or three minutes, which makes it a reasonable starter while the register is taken. Print four different ones, cut them into quarters and you have a week of warm-ups. The 4x4 works well in pairs, with one child adding and the other checking, because the mistakes are almost always arithmetic rather than logic.
The useful conversation after the puzzle is why the magic sum is what it is. The numbers 1 to 9 add to 45, and those nine numbers are split across three rows, so each row must carry 15. The same reasoning gives 34 for the 4x4 and 65 for the 5x5. Children who see that stop treating the sum as a number handed to them and start working it out for themselves, which is the point at which a magic square stops being a puzzle and starts being algebra.
One common sticking point is worth naming in advance: on a 3x3, the centre cell is always 5 and the corners are always even. A child who has spotted that will solve the easy puzzles almost instantly, so move them up to 4x4 rather than to a harder 3x3.
Frequently Asked Questions
What is the magic sum for a 3x3 magic square?
It is 15. The numbers 1 to 9 add up to 45, and that total is shared equally across three rows, so each row, column and diagonal comes to 15.
How do you solve a magic square?
Find a row, column or diagonal with only one empty cell, add up the numbers already in it, and subtract that from the magic sum to get the missing number. Fill it in and repeat, since each answer usually opens up another line with a single gap.
What is the magic sum for a 4x4 and a 5x5?
A 4x4 magic square uses 1 to 16 and every line adds to 34. A 5x5 uses 1 to 25 and every line adds to 65.
Does every puzzle have only one answer?
Yes. After the blanks are chosen, the grid is tested and numbers are put back until exactly one arrangement completes it, so a child who solves it correctly will match the answer key.
Can I print the answer key?
Yes. Switch to the Solution tab and print from there. The sheet is headed Answer Key and the numbers the child had to work out are printed in green so they stand out from the given ones.
What age are magic square puzzles suitable for?
The 3x3 grid suits roughly ages seven and up once addition to 20 is comfortable. The 4x4 fits upper primary, and the 5x5 is better kept as a challenge for confident older pupils.
Can I get a different puzzle with the same settings?
Press Generate New Puzzle or the New Puzzle button. Each press builds a fresh grid and rotates or flips it at random, so consecutive sheets do not repeat.
Is there a way to save the puzzle as an image?
Download Image saves the grid currently on screen as a PNG at twice normal resolution, which is enough to paste into a worksheet, a slide or a class newsletter without it looking blurry.