Navigation

HomeImage ToolsCode ToolsMath ToolsDate ToolsGeneratorsUtilities
Color ToolsText ToolsPDF Tools

Generate Sierpinski Carpet

Draw the Sierpinski Carpet fractal — recursively removing center squares to create a self-similar pattern.

About this generator

Set the iteration depth, pick a fill and background color, then hit Draw — the carpet builds itself by slicing each square into a 3×3 grid and dropping the middle one. Five iterations gives you 32,768 little squares; six pushes that to 262,144, which is about where most browsers start to sweat. And everything runs in your browser. Nothing gets uploaded.

FAQ

How many iterations can I use?
Up to 6 iterations. At iteration 6, there are 8⁶ = 262,144 filled squares, which is near the practical rendering limit.

What is the fractal dimension?
The Hausdorff dimension of the Sierpinski carpet is log(8)/log(3) ≈ 1.8928, making it denser than the Sierpinski triangle (≈1.585).

What is the area at each iteration?
The remaining area fraction is (8/9)ⁿ. After 5 iterations, about 57% of the original area remains.

How is this different from the Sierpinski triangle?
The carpet works with squares in a 3×3 grid removing the center, while the triangle uses triangles in a 2×2 grid removing the center triangle.

Related Tools