Draw a Magic Square
Create a matrix of numbers with rows and cols having same sum. Runs entirely in your browser, so your data never leaves your device.
Output
The result appears here as you type.
How to use Draw a Magic Square
- 1. Choose a size. There's nothing to paste here. Start by setting Size to the number of rows and columns you want, such as 3 for a classic 3 by 3 square.
- 2. Understand the magic constant. The generator arranges numbers so every row, column and both diagonals add up to the same magic constant, for example 15 in the classic 3 by 3 square.
- 3. Copy the magic square. Copy the grid of numbers from the output pane into a puzzle document, worksheet or wherever the finished magic square is needed.
When to use Draw a Magic Square
Draw a Magic Square generates a grid of numbers where every row, column and diagonal sums to the same magic constant. It removes the manual work of applying the Siamese method or another construction rule by hand.
- Preparing a math enrichment worksheet. A teacher wants students to verify the row and column sums of a real magic square rather than working through the construction algorithm themselves first.
- Designing a puzzle for a game or escape room. A puzzle hunt needs a magic square of a specific size as a clue element, where solvers must find or verify the magic constant to proceed.
- Studying the Siamese method construction. You're learning how odd-order magic squares are built and want to generate examples of different sizes to check your understanding of the diagonal-fill technique.
- Creating a decorative number grid. You want an aesthetically balanced grid of numbers for a design or print project, and a magic square's built-in symmetry provides that structure for free.
Examples
The classic 3×3 magic square (magic constant 15)
Output
8 1 6 3 5 7 4 9 2
A 4×4 magic square (magic constant 34)
Output
16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1
About the Draw a Magic Square tool
Draw a Magic Square runs as plain JavaScript in your browser tab, with no server behind it. Create a matrix of numbers with rows and cols having same sum. Whatever you put in stays on your device from start to finish.
The tool is part of EditSafely's Number Tools section, 194 single-purpose utilities built around the same idea: open the page, get the result, keep your data to yourself.
You can shape the output with the Size setting, and the result refreshes the moment you change it. 2 worked examples further down the page show exactly what the tool produces for real inputs.
That local-first design has practical benefits beyond privacy. The tool keeps working on a flaky connection once the page has loaded, results are instant because nothing round-trips to a server, and it is safe to use with confidential material.
Frequently asked questions
Is Draw a Magic Square free to use?
Yes, it is completely free. All 2,658 tools on EditSafely work without an account, a subscription or usage limits.
Does the generator send anything to a server?
Everything happens locally. Your browser downloads the tool's code once, then does all the processing itself; nothing you enter is transmitted, stored or logged. You can even go offline after the page loads and it will still work.
How do I get a different result?
Run the generator again. Each run is computed fresh on your device, and any options you change are applied to the next result immediately.
Do I need to sign up or install anything?
No. The tool works in any modern browser on desktop, tablet or phone. There is no account to create, no extension to add and no software to install.
How do I use the result?
The output panel has a one-click copy button, and you can keep refining the input while you work; the result updates in place as you type.