Sierpinski Fractal Generator
The Sierpinski triangle, formed by recursively removing triangles. Customize and download as PNG.
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
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.
Iterations: 5
Color: #1e293b
Size: 800px
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.
Iterations: 7
Color: #22d3ee
Size: 1600px
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.
Iterations: 3
Color: #6366f1
Size: 600px
600×600 PNG with 27 triangles — simple enough to auto-trace as vector paths
Who Uses This
Print fractal diagrams for lessons on recursion and self-similarity.
Export low-iteration shapes as design elements or pattern bases.
Visualize recursive algorithms without writing rendering code first.
Generate fractal art for wallpapers, 3D-printing templates, or laser cutting files.
Common Mistakes
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.
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.
A 400px image looks fine on screen but pixelates when printed. For anything physical — posters, handouts, stickers — go with at least 1200px.
Technical Details
- Processing: 100% client-side (HTML5 Canvas API)
- Browser Support: Chrome, Firefox, Safari, Edge
- Max Canvas: Up to 2000×2000 pixels
- Export Format: PNG with transparency support
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.