Magic Square Generator screenshot

Magic Square Generator

Generate a magic square of order 3 to 9 and show that every row, column and diagonal sums to the same constant.

Privacy First
0 Runs
Updated 2026-11-22
Runs in your tab
No upload
Proven answer
Print and text download

What this page makes

Builds a magic square at the size you choose, rotates or complements it from the seed, and checks every row, column and diagonal against the magic constant before showing it.

How to use it

Choose the order and press Generate. The seed changes the orientation and whether the square is complemented; it does not change the fact that every line sums to the same constant. Check any row, column or diagonal against the printed constant.

Worked example: order 5, seed magic-demo becomes a 5×5 square using 1 to 25 once, every line summing to 65.

What it proves

Odd orders use the Siamese method, doubly even orders use the complement method, and order 6 uses a checked classic square; the seed chooses a rotation, reflection or complement. The finished grid must contain every number from 1 to n² once and sum to n(n²+1)/2 on every row, column and both diagonals.

What it refuses

A size outside 3 to 9 is refused. A constructed square that fails the sum check is an internal error and is never shown.

Where it runs

The puzzle is generated and solved in this tab: there is no upload, no network request, no stored seed and no model, so nothing you type leaves your device. The same seed and options rebuild the same puzzle exactly.

The rest of the family

The other puzzle generators are listed under Tabletop & Game Tools: killer sudoku, kakuro, KenKen, futoshiki, nonograms, slitherlink, Hashi, word search, crossword, magic squares and buzzword bingo.

Builds a magic square at the size you choose, rotates or complements it from the seed, and checks every row, column and diagonal against the magic constant before showing it.

Odd orders use the Siamese method, doubly even orders use the complement method, and order 6 uses a checked classic square; the seed chooses a rotation, reflection or complement. The finished grid must contain every number from 1 to n² once and sum to n(n²+1)/2 on every row, column and both diagonals. Every puzzle is generated, solved or checked in this tab: there is no upload, no network request, no stored seed and no model, so nothing you type leaves your device.

Worked example: order 5, seed magic-demo becomes a 5×5 square using 1 to 25 once, every line summing to 65.

Before the puzzle is shown, the same solver is run over it: the answer, the solution count and the node cap are printed under the board, so the proof is checkable rather than promised.

How to use the magic square generator

Choose the order and press Generate. The seed changes the orientation and whether the square is complemented; it does not change the fact that every line sums to the same constant. Check any row, column or diagonal against the printed constant.

Every puzzle is generated, solved or checked in this tab: there is no upload, no network request, no stored seed and no model, so nothing you type leaves your device.

  • Square size — one of 3, 4, 5, 6, 7, 8, 9
  • Seed (recorded, not used) — typed text

What the page proves

Builds a magic square at the size you choose, rotates or complements it from the seed, and checks every row, column and diagonal against the magic constant before showing it.

Odd orders use the Siamese method, doubly even orders use the complement method, and order 6 uses a checked classic square; the seed chooses a rotation, reflection or complement. The finished grid must contain every number from 1 to n² once and sum to n(n²+1)/2 on every row, column and both diagonals.

  • Domain: Orders 3 to 9; the constant is n(n²+1)/2 and is printed with the grid.
  • The seed is printed with the puzzle and rebuilds it exactly: the same seed and options always produce the same grid.
  • A generation that cannot prove its answer inside the stated node cap is refused with the seed kept, rather than printed with an unchecked answer.

What it refuses, and what it leaves out

A size outside 3 to 9 is refused. A constructed square that fails the sum check is an internal error and is never shown.

  • Not the right page for: a square with numbers other than 1 to n²
  • Not the right page for: a search for every magic square of an order

What to Expect

Best for

  • a number-pattern lesson
  • a quick puzzle for a maths club
  • a printable square to check by hand

Not ideal for

  • a square with numbers other than 1 to n²
  • a search for every magic square of an order

What this tool keeps

  • every number from 1 to n² exactly once
  • the constant printed with the grid
  • the seed's orientation

What may need cleanup

  • choosing a smaller order when you want to check by hand
  • remembering that many different squares share the same constant

Common errors

  • a repeated or missing number fails the check
  • a line that misses the constant is never printed

Example use cases

  • a maths-club warm-up
  • a patterns lesson
  • a printed check-by-hand exercise

Sample input

order 5, seed magic-demo

Sample output

a 5×5 square using 1 to 25 once, every line summing to 65

Who this is for

  • Students
  • Teachers
  • Number-puzzle fans

Frequently asked questions

Is my data sent anywhere?

Every puzzle is generated, solved or checked in this tab: there is no upload, no network request, no stored seed and no model, so nothing you type leaves your device.

What can I download or print?

Print shows the puzzle and, if you open it, the answer key. Download writes a plain text file with the seed, the facts the page proved and the answer key; both are produced in this tab and neither is uploaded.

Why does the page print a seed?

So a puzzle can be rebuilt exactly. The same seed and the same options give the same puzzle on any machine, because the only randomness is a hash of the seed. Leave the field blank for a fresh one; the seed that was used is written back into the field.

Is this the only magic square of its order?

No. Most orders have many magic squares, and the page prints one arrangement and proves its sums. The facts line says the arrangement is checked, not that it is unique.

What does the seed change?

It selects a rotation, a reflection or the complement (each number replaced by n²+1 minus it). All three preserve every sum, so the proof is the same while the printed square changes.

Why is order 6 built differently?

Singly even orders need a different construction from odd and doubly even ones. The page ships a checked order-6 square and refuses other singly even orders rather than pretend the same method works.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.