Magic Square Generator
Generate self-checking magic square math puzzles in 3×3, 4×4, or 5×5, with easy/medium/hard difficulty and an answer key.
About this magic square generator
A magic square is a grid filled with consecutive numbers — 1 through 9 for a 3×3, 1 through 25 for a 5×5, and so on — arranged so every row, every column, and both diagonals add up to the same total, the "magic sum." This tool builds a genuine, mathematically correct magic square for whichever size you choose, then hides some of the numbers for students to work out, leaving the rest visible as starting clues.
Difficulty controls how many numbers are given versus hidden: Easy leaves most of the grid filled in, Hard hides most of it, and Medium sits in between. Because a magic square is self-checking by nature, a student can verify their own work as they go — if a row or column doesn't add up to the same total as the others, something's wrong, without needing to check against an answer key first.
Generating more than one puzzle at a time doesn't just repeat the same grid with different blanks — each puzzle applies a random rotation or mirror-flip to the underlying square first. Rotating or reflecting a magic square keeps every row, column, and diagonal sum exactly the same, so every puzzle in a set stays completely valid while still looking genuinely different from the others.
This generator currently covers 3×3, 4×4, and 5×5 grids. 6×6 and other so-called "singly-even" sizes use a meaningfully more complex construction method and aren't included in this version.
Nothing you configure is uploaded anywhere; every puzzle and its answer key are generated locally in your browser.
Frequently asked questions
What is a magic square?
A grid filled with consecutive numbers so that every row, column, and diagonal adds up to the same total. This tool generates a genuinely valid one for each puzzle, then hides some numbers for students to fill in.
How is the difficulty controlled?
By how many numbers are hidden versus given as starting clues. Easy shows most of the grid, Hard hides most of it, and Medium is in between.
Are multiple puzzles actually different from each other?
Yes. Each one applies a random rotation or flip to the base square before hiding numbers, which keeps every sum correct while giving each puzzle a genuinely different layout.
Why isn't 6×6 available?
6×6 belongs to a category of magic squares ("singly-even" sizes) that needs a considerably more complex construction method than 3×3, 4×4, or 5×5, and isn't included in this version.
Is my configuration saved or uploaded anywhere?
No. Everything is generated locally in your browser; nothing is sent anywhere.