Sierpinski Triangle Generator

Draw the Sierpinski triangle, by dividing a triangle or by playing the chaos game.

This is a free online Sierpinski triangle generator. Choose how many times the triangle is divided, pick the colors, and download the result as a PNG image with a transparent background, ready to print or to use in a project.

The Sierpinski triangle is the simplest fractal to describe: take a triangle, cut out the triangle formed by the middles of its sides, and repeat forever on the three triangles that are left. The result is a shape made of three copies of itself, each one half the size — the definition of self similarity.

This tool can draw it in two completely different ways that arrive at exactly the same picture: by dividing the triangle step by step, and by playing the chaos game, which places millions of random points and lets the fractal appear on its own.

Everything runs directly in your browser. No image is uploaded to a server, and nothing needs to be installed.

Fractal options

Shape
Every iteration replaces each part of the fractal by several smaller copies of it.
View
Use the mouse wheel over the image to zoom, and drag the image to move it.
Colors
The gradient goes from the bottom to the top of the triangle.
Image size
Image details:
image: 800 x 600 px
triangles: 0
drawn in: 0 ms

Use the mouse wheel over the image to zoom in and out, and drag the image to move it. On a phone, use one finger to move the image and two fingers to zoom. The checkered squares show the transparent areas of the image: they are not part of the downloaded PNG file.

How to generate a Sierpinski triangle?

  1. Choose how it is drawn - "Divide the triangle" draws the exact fractal, with crisp edges at any resolution. "Chaos game" throws random points instead, which gives a grainier, hand drawn look.
  2. Choose the number of divisions - Each division multiplies the number of triangles by 3: level 6 has 729 triangles and level 9 has almost twenty thousand. Above level 8 the smallest triangles get close to the size of a pixel, so raise the resolution as well.
  3. Choose the colors - Use one flat color, or a gradient between two colors that follows the height of the triangle. Turn off "Fill the shape" to get an outline drawing instead of solid triangles.
  4. Make the background transparent (optional) - Turn on "Transparent background" to download a PNG you can place over anything. The checkered squares under the image show which parts are transparent.
  5. Frame the image - Use the mouse wheel over the image to zoom, drag it to move it, and turn the rotation slider to tilt the triangle. "Reset view" puts everything back.
  6. Choose the resolution - Pick one of the common resolutions or type any width and height, up to 4K.
  7. Download the image - Click "Download PNG image" to save exactly what you see.

Settings

FieldDescription
How it is drawn"Divide the triangle" builds the fractal exactly, drawing every small triangle. "Chaos game" places random points that slowly reveal the same shape.
Number of divisionsHow many times each triangle is divided into three. The number of triangles is 3 raised to this number, so it grows very quickly.
Number of pointsOnly used by the chaos game: how many random points are placed. More points make the fractal look denser and reveal smaller details.
Zoom, Rotation, MarginHow the fractal is framed inside the image. The margin is the empty space left around the drawing, in pixels.
ColoringOne flat color, or a gradient between two colors that follows the height of each triangle inside the drawing.
Fill the shapeDraws solid triangles. Turn it off to draw only the outlines, which gives a wireframe look and lets the background show through.
Line thicknessThe thickness of the outlines, in pixels, when the shape is not filled.
Transparent backgroundLeaves the background of the PNG transparent, so the fractal can be placed over any image or color.
Resolution / Width / HeightThe size of the generated image, in pixels.

What is the Sierpinski triangle?

Start with a filled triangle. Mark the middle point of each of its three sides, and remove the triangle they form in the center. Three smaller triangles are left, each one half as wide as the original. Do the same to each of them, and then to each of the nine that result, and so on forever. What remains after infinitely many steps is the Sierpinski triangle.

It was described by the Polish mathematician Wacław Sierpiński in 1915, although the same pattern appears in Italian church floors from the 13th century, six hundred years before anyone called it a fractal.

Two numbers describe how strange the shape is. Its area is zero: at every step three quarters of the remaining area survives, and (3/4)n goes to zero. Its perimeter is infinite: at every step the total length of the borders is multiplied by 3/2, and that grows without limit. A shape with no area and an endless border does not fit the usual idea of a curve or a surface, and that is exactly why fractal geometry needed a new kind of dimension.

The fractal dimension of the Sierpinski triangle is log 3 / log 2 ≈ 1.585. The reason is simple: the shape is made of 3 copies of itself, each scaled by 1/2. A line made of 2 copies at half size has dimension 1, a square made of 4 copies at half size has dimension 2, and this shape sits between them.

The chaos game

The second drawing method looks like it cannot possibly work. Mark the three corners of a triangle and pick any starting point. Then repeat this, forever:

  1. Choose one of the three corners at random.
  2. Move to the point halfway between where you are and that corner.
  3. Put a dot there.

The dots are placed in a completely unpredictable order, and yet after a few thousand of them the Sierpinski triangle appears — and no dot ever lands in a hole. The reason is that the halving step can never take you into a removed region: the three "jump to a corner and halve" rules are precisely the three copies that build the fractal, so the set of points they can reach is the fractal. The random choices only decide the order in which the picture fills in.

This is the same mechanism behind the Barnsley fern, which uses four transforms instead of three, chosen with different probabilities.

Frequently Asked Questions (FAQ)

Is this Sierpinski triangle generator free to use?

Yes, this tool is 100% free and works directly in your browser, with no installation and no sign-up required.

Are the images uploaded to a server?

No. The fractal is drawn by your own browser and the image never leaves your computer.

Can I use the generated images in my own projects?

Yes. The images come from a geometric rule, and you can use them in websites, posters, worksheets, games, printed material and anywhere else.

Can I download it with a transparent background?

Yes. Turn on "Transparent background" and the PNG will have no background at all, so you can place the triangle over any color or image.

Which drawing method should I use?

Use "Divide the triangle" when you want a clean, exact image, especially for printing. Use the chaos game when you want the grainy texture of random points, or when you want to show how the fractal emerges from randomness.

Why do the smallest triangles disappear when I raise the divisions?

Because they become smaller than one pixel. Either raise the resolution of the image, or zoom in with the mouse wheel to look at one part of the fractal closely.

What is the area of the Sierpinski triangle?

Zero. Each step keeps three quarters of the area of the previous one, and repeating that forever leaves nothing. The perimeter, on the other hand, grows by half at every step and becomes infinite.

What is its fractal dimension?

log 3 / log 2, which is about 1.585. It is made of 3 copies of itself at half the size, which puts it between a line (dimension 1) and a filled surface (dimension 2).

Is the Sierpinski triangle related to Pascal's triangle?

Yes, and the connection is beautiful: colour every odd number in Pascal's triangle and leave the even ones blank, and the Sierpinski triangle appears. The same pattern also shows up in the Rule 90 cellular automaton.

Where can I see other fractals?

Try the Koch Snowflake Generator, the Dragon Curve Generator, the Barnsley Fern Generator and the Mandelbrot Set Generator.

Related tools

Koch Snowflake Generator

Koch Snowflake Generator

Draw the Koch snowflake, the antisnowflake and the Koch curve.
Dragon Curve Generator

Dragon Curve Generator

Draw the dragon curve, the fractal you get by folding a strip of paper.
Barnsley Fern Generator

Barnsley Fern Generator

Draw the Barnsley fern with the chaos game, using four affine transforms.
Mandelbrot Set Generator

Mandelbrot Set Generator

Draw the Mandelbrot set, zoom into it with the mouse and download the image.
Turtle Graphics

Turtle Graphics

Easily create Turtle Graphics images and animations.
Maze Generator

Maze Generator

Generate random mazes and download them as images.