Tools

Home
Base64 Encode/DecodeString to HexHash GeneratorUTF-8 Encode/DecodeURL Encode/Decode

Sierpinski Fractal Generator

The Sierpinski triangle, formed by recursively removing triangles. Customize and download as PNG.

Your data never leaves your browser
SETTINGS0 values
PREVIEW0 values
Ready·Ready

Pick an iteration depth and color, hit Convert, and watch the Sierpinski triangle build itself on a canvas — from 3 triangles at depth 1 to over 2,000 at depth 7. Download the result as a PNG sized up to 2000px for print or screen.

And everything runs in your browser. Nothing gets uploaded.

How It Works

Set Depth & Color
→
Recursive Subdivision
→
Render PNG

The algorithm starts with one large triangle. At each iteration, it splits every existing triangle into three smaller ones by connecting the midpoints of each side — and skips the middle triangle. This process repeats recursively until it reaches your chosen depth. The result is that classic self-similar pattern where every piece looks like a smaller copy of the whole thing.

Examples

Math Class Handout

A teacher needs a clean fractal image for a worksheet on geometric recursion.

INPUT
Iterations: 5 Color: #1e293b Size: 800px
OUTPUT
800×800 PNG with 243 filled triangles in dark slate

Poster Background for a Science Fair

A student wants a high-res fractal background. Needs large canvas and a bright color that pops on a dark poster board.

INPUT
Iterations: 7 Color: #22d3ee Size: 1600px
OUTPUT
1600×1600 PNG with 2,187 cyan triangles — crisp enough for a large print

Quick Logo Accent

A designer grabs a low-iteration version to trace in Illustrator.

INPUT
Iterations: 3 Color: #6366f1 Size: 600px
OUTPUT
600×600 PNG with 27 triangles — simple enough to auto-trace as vector paths

Who Uses This

🎓 Math Teachers

Print fractal diagrams for lessons on recursion and self-similarity.

🎨 Designers

Export low-iteration shapes as design elements or pattern bases.

👨‍💻 CS Students

Visualize recursive algorithms without writing rendering code first.

🖼️ Hobbyists

Generate fractal art for wallpapers, 3D-printing templates, or laser cutting files.

Common Mistakes

Setting iterations too high right away

At depth 10+, the browser may lag or freeze — you're asking it to draw over 59,000 triangles. Start around 5 or 6, then increase one step at a time to see where your machine tops out.

Picking a color too close to the background

If you choose white or very light gray on a white canvas, the fractal is invisible. Switch to a darker shade, or change the theme to dark mode so the canvas background flips.

Using a tiny canvas for print

A 400px image looks fine on screen but pixelates when printed. For anything physical — posters, handouts, stickers — go with at least 1200px.

Technical Details

Frequently Asked Questions

What is a Sierpinski triangle?

It's a fractal named after Polish mathematician Wacław Sierpiński. You start with a filled triangle, cut out the middle, and repeat for each remaining piece. The shape that's left after infinite repetitions has zero area but infinite perimeter — which is a weird thing to wrap your head around.

How many triangles does each iteration produce?

Each level triples the triangle count. Depth 1 has 3, depth 2 has 9, depth 5 has 243, depth 7 has 2,187. The formula is 3^n where n is the iteration number.

Why does my browser slow down at high iterations?

The recursive calls grow exponentially. At iteration 10 the algorithm draws 59,049 individual triangles — each one a separate canvas path operation. Most machines handle 7 or 8 without trouble. Beyond that depends on your hardware.

Can I use the generated image commercially?

Yes. The Sierpinski triangle is a mathematical object — nobody owns it. The PNG you generate here is yours to use however you want, including in commercial projects.

Is the fractal rendered as vector or raster?

Raster. The Canvas API outputs pixels, so the download is a PNG bitmap. If you need vector output, generate a low-iteration version here and trace it in a tool like Inkscape or Illustrator. Three or four iterations trace cleanly.

Share: