Barnsley Fern Generator

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

This is a free online Barnsley fern generator. Choose how many points are placed, pick the colors of the gradient, and download the result as a PNG image.

The Barnsley fern is the most convincing argument that nature's shapes can come from very little information. The whole plant — stem, leaflets, the curl at the tip, the way each leaflet repeats the shape of the whole frond — is produced by four simple formulas and a random number generator. There is no drawing, no model of a plant, and no image: only twenty four numbers.

Each point is placed by picking one of the four formulas at random and applying it to the previous point. The points land in an unpredictable order, and yet the fern always appears.

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

Fractal options

Shape
More points make the fractal darker and show more of its details.
View
Use the mouse wheel over the image to zoom, and drag the image to move it.
Colors
The gradient goes from the base of the stem to the tip of the fern.
Image size
Image details:
image: 800 x 600 px
points: 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 Barnsley fern?

  1. Choose the variant - The classic Barnsley fern, or the Cyclosorus fern, which uses a different set of four transforms and grows a narrower frond with straighter leaflets.
  2. Choose the number of points - This is the main control. Fifty thousand points already show the shape; half a million gives a solid, detailed fern; two million fills in the finest leaflets. The image is drawn little by little, so you can see it forming.
  3. Choose the colors - Use a gradient between two colors, which follows the height of the plant from the base of the stem to the tip, or a single flat color.
  4. Adjust the size of the points - One pixel gives the finest detail. Two or three pixels make a bolder, denser fern that needs fewer points.
  5. Frame the image - Zoom with the mouse wheel to look closely at a leaflet, drag the image to move it, and use the rotation slider to tilt the plant. Raise the number of points when you zoom in, otherwise the detail looks sparse.
  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
VariantThe set of four transforms that is used: the classic Barnsley fern, or the Cyclosorus fern, which produces a different species.
Number of pointsHow many points the chaos game places. This controls the density of the plant: too few and the fern looks like a spray of dust, many and it becomes a solid leaf.
Size of the pointsThe size of each dot in pixels. Keep it at 1 for the finest detail, and raise it when you want a bolder plant without waiting for millions of points.
Zoom, Rotation, MarginHow the fern 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 the plant, from the base of the stem to the tip of the fern.
Transparent backgroundLeaves the background of the PNG transparent, so the fern can be placed over any color or image.
Resolution / Width / HeightThe size of the generated image, in pixels.

How four formulas draw a plant

The fern is an iterated function system. Start at the point (0, 0). Then, millions of times, pick one of four transformations at random and apply it to the current point, drawing a dot wherever you land. Each transformation is an affine map: it can stretch, squash, rotate, flip and move a point, but it always turns straight lines into straight lines.

What makes the fern readable is that each of the four transforms has a clear job, and is chosen with a very different probability:

TransformChosenWhat it draws
The first one1% of the timeFlattens everything onto a vertical line: this is the stem.
The second one85% of the timeShrinks the plant slightly, rotates it a little and moves it up: this is what stacks a smaller copy of the whole fern above the previous one, creating the main frond.
The third one7% of the timeMakes a small, strongly rotated copy: the leaflets on the left.
The fourth one7% of the timeThe mirror image of the third one: the leaflets on the right.

The probabilities are not decoration: they are chosen to match how much area each transform is responsible for, so that every part of the fern receives points at the same rate. That is why the stem, which is a thin line, needs only 1% of the points, while the main frond needs 85%.

The fern was published by the British mathematician Michael Barnsley in his 1988 book Fractals Everywhere. His larger point was practical: if four formulas can encode a fern, then images in general might be stored as the transforms that generate them rather than as pixels. That idea became fractal image compression.

Frequently Asked Questions (FAQ)

Is this Barnsley fern 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 fern is calculated 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 mathematical formula, and you are free to use them in websites, wallpapers, posters, videos, games and printed material.

Why does the fern look grainy or full of holes?

There are not enough points yet. Raise "Number of points" — half a million is a good value for a detailed fern — or raise the "Size of the points" to 2 pixels, which fills the gaps much faster.

Why does the image appear little by little?

Because the points are placed in batches, so that the page keeps responding while millions of them are being calculated. The progress bar under the image shows how far it is.

Does the fern look different every time?

The individual dots land in a different order every time, because the transforms are chosen at random. The shape, however, is always exactly the same: the randomness only decides the order in which the picture fills in, not what is drawn.

Is the fern really made of only four formulas?

Yes. Each of the four transforms is defined by six numbers plus a probability, so the entire plant is described by fewer than thirty numbers. That is far less information than a photograph of a fern.

Why do I keep seeing the same shape inside the leaflets when I zoom in?

Because the fern is self similar: the second transform places a smaller copy of the whole plant a little higher up, so every leaflet is, in miniature, a copy of the entire fern. Remember to raise the number of points when you zoom, or the detail will look sparse.

What is the chaos game?

It is the method used here: jump to a random transform, apply it, draw a dot, repeat. The same method draws the Sierpinski triangle with three transforms instead of four.

Where can I see other fractals?

Try the Sierpinski Triangle Generator, the Koch Snowflake Generator, the Dragon Curve Generator and the Mandelbrot Set Generator.

Related tools

Sierpinski Triangle Generator

Sierpinski Triangle Generator

Draw the Sierpinski triangle, by dividing a triangle or by playing the chaos game.
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.
Mandelbrot Set Generator

Mandelbrot Set Generator

Draw the Mandelbrot set, zoom into it with the mouse and download the image.
Procedural Image Generator

Procedural Image Generator

Create images procedurally from basic shapes and mathematical formulas.
Turtle Graphics

Turtle Graphics

Easily create Turtle Graphics images and animations.