Boneyard Tools

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

  1. Pick an order (3 or more) and press Generate to build a magic square.
  2. Optionally set a start value and step to shift the numbers, or a seed to rotate the layout.
  3. 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