Magic Square Generator and Solver
Build a magic square of any size, complete a partly filled one, or test whether a grid you have is truly magic. The generator uses the classic Siamese, doubly even and Strachey constructions, so every row, column and diagonal lands on the same magic constant.
How to make a magic square
- Pick an order (3 or more) and press Generate to build a magic square.
- Optionally set a start value and step to shift the numbers, or a seed to rotate the layout.
- Switch to Solve or Verify to complete a partial square or check one you paste in.
Examples
Generate a 5x5 magic square
order = 5
magic constant 65; every row, column and diagonal sums to 65
Frequently asked questions
What is the magic constant?
It is the sum every row, column and diagonal must reach. For a normal n by n square using 1 to n squared it equals n times (n squared plus 1) divided by 2, so a 3x3 sums to 15 and a 4x4 to 34.
Which orders can I generate?
Any whole order of 3 or more. There is no magic square of order 2. The tool automatically picks the right method: Siamese for odd orders, a diagonal swap for orders divisible by 4, and the Strachey method for singly even orders like 6 and 10.
Can it solve a partly filled magic square?
Yes. Leave blank cells empty (or type a dot) and the solver fills the rest by backtracking, then tells you whether the completion is unique. It is built for small squares, where this is the classic puzzle.
Can the numbers start somewhere other than 1?
Yes. Set a start value and a step and the square uses that arithmetic sequence instead of 1 to n squared. It stays magic, just with a different magic constant.
Is my data sent anywhere?
No. Generating, solving and verifying all run entirely in your browser, so nothing is uploaded to a server.
Learn more
- How magic squares are built, order by order
The three classical constructions behind every magic square: the Siamese method for odd orders, the diagonal method for doubly even orders, and the Strachey method for singly even orders.
Related tools
Sudoku Solver
Solve any Sudoku puzzle instantly and generate new ones. Type the grid, get the unique solution, see candidates and clue counts. Runs in your browser.
Truth Table Generator
Generate a truth table from any boolean expression. Supports AND, OR, NOT, XOR, NAND, NOR, XNOR, IMPLIES and IFF. Runs in your browser.
Permutation and Combination Calculator
Calculate permutations (nPr) and combinations (nCr) for choosing r items from n. See both results with the formulas and factorials, updated live.
Number to Words
Convert numbers to written words instantly. Spell out whole numbers or write a cheque amount in dollars and cents, then copy the result. Free and private.
Annulus Area Calculator
Calculate the area of an annulus, the ring between two concentric circles, from its outer and inner radius. Returns both circumferences and width too. Free.
Area Calculator
Find the area of a circle, square, rectangle, triangle, trapezoid, parallelogram, ellipse, sector or rhombus. Free and runs in your browser.