PLAY · TEST · UNDERSTAND
Magic Square Generator
Build a normal magic square of order three through nine with the Magic Square Archive generator. A normal square uses every integer from one to the square of its order exactly once, with equal totals in each row, column, and both main diagonals. This tool uses constructive methods and deterministic rotations or reflections; it does not enumerate every possible square or sample squares uniformly at random.
Magic square generator
Use each integer from 1 to 9 once. Every row, column and both diagonals must sum to 15.
Each new square is a deterministic rotation or reflection of a valid construction; eight variants cycle in order.
Transform variant 1 of 8
- Magic constant
- 15
Select this text to copy it; rows are separated by newlines and numbers by tabs.
Choose an order and understand the total
The order is the number of cells along each side, not the number of cells overall. An order of three gives nine cells, while an order of nine gives eighty-one. For order n, the magic constant is M = n(n² + 1)/2. The total is 15 for order three, 34 for order four, 111 for order six, and 369 for order nine. Changing the order changes both the size and the required line total.
Construction depends on the order
Normal magic squares exist for every order offered here, but the construction is not identical across the range. Orders three, five, seven, and nine are odd. Orders four and eight are doubly even, meaning divisible by four. Order six is singly even: even but not divisible by four. These families require different construction rules. The generator builds a valid arrangement directly rather than searching through every permutation of the entries. Its output is a constructed example, not a list of all solutions.
Rotations and reflections preserve the square
A quarter-turn, half-turn, or mirror reflection changes where the numbers appear without changing the magic constant. Rows and columns exchange roles or reverse direction, and the two main diagonals remain main diagonals. Consequently, these transformations preserve the defining sums and the set of entries. A base square has up to eight orientations under rotations and reflections. These are symmetry variants, not evidence that every possible normal magic square has been generated. Deterministic transformations should not be described as uniform random sampling.
Read and verify the generated result
Check a result by confirming its entries run from one through n² with no repeats, then add every row, every column, and both corner-to-corner diagonals. All these sums must equal M. Other diagonal paths are not part of the ordinary magic-square definition. Comparing orientations is useful for studying symmetry or choosing a layout for a puzzle. The generator does not solve arbitrary grids with supplied clues; use it to construct complete normal squares within the supported order range.