By Tim King · Updated
L-System Tree Generator
Fractal Trees and Plants Online, Free PNG
OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.
How the L-System Tree Generator works
This L-system tree generator grows plants from rewriting rules. An L-system grows a plant from a sentence. Start with one letter, replace every letter by a longer string according to a rule, repeat a few times, and then read the result as turtle-graphics commands: draw forward, turn left, turn right, remember this spot, go back to it. The page does that for five classic plant rules and lets you save the tree as a PNG.
L-system tree generator: what to know first
Lindenmayer invented these systems in 1968 to describe how algae cells divide, and they turned out to draw convincing plants with almost no code. Each preset is an axiom, the starting string, and one or two rules that say what each letter becomes. The Fractal tree preset starts from X and uses X → F+[[X]−X]−F[−FX]+X and F → FF. After five iterations that is a string of several thousand characters.
Reading the string, F draws a segment, + and − turn by the branch angle, and [ and ] save and restore the turtle's position and heading. The brackets are what make it a tree: every time the turtle finishes a side branch it pops back to the fork and carries on with the trunk. Letters with no drawing meaning, like X, only exist to carry the growth rule.
Iterations is how many times the rules are applied. Each one adds a level of branching and roughly doubles the detail; six or seven gives a full canopy but the string grows fast, so the page caps it. Branch angle is the turn made by + and −. Each preset has a textbook angle, but sweeping it changes the plant from a cypress at 10° to a sprawling bush at 45°. Randomness jitters every angle and segment length by a small amount chosen from the seed, which is the difference between a diagram and something that looks grown. At 0 the tree is perfectly symmetric and Regenerate does nothing; at 5 each seed is a different individual of the same species.
Colour shades from a brown trunk to green or autumn tips by branch depth, and the stroke weight thins toward the tips. Mono draws everything in one colour for a silhouette.
Export. The string is regenerated and redrawn at the chosen size, with segment lengths scaled to the canvas height, so the tree fills a phone export as well as a desktop one.
FAQ
Why does the tree go off the top at high iterations?
Segment length is divided by a fixed factor per iteration to keep the tree roughly the same height, but some presets grow faster than others. Lower the iterations by one or use a taller export size.
Can I write my own rules?
Not on this page; the presets cover the standard textbook plants from Prusinkiewicz and Lindenmayer's The Algorithmic Beauty of Plants. The Weed preset is their figure 1.24a, Fern is 1.24f, Fractal tree is the widely copied example from Wikipedia.
Why is it slow at 7 iterations?
The Bushy tree string has about 250,000 characters at depth 7 and every F draws a line. Expect a second or so, and a few seconds at 4K.
How is this related to the Koch snowflake and Sierpinski triangle?
They are L-systems too, without brackets. The Koch curve is F → F+F−−F+F with 60° turns, and the Sierpinski arrowhead uses two symbols with 60° turns. Both have their own pages here.
See also: all Generative Art tools, Images, Audio, Video & Screen, PDF, SVG, Simulations & Screensavers, Chart Makers, 3D Model Viewers, Drawing Pads, Mockups & 3D Making, Diagram Makers, 3D Science, Tracker Music.
Related tools
Sierpinski Triangle Generator
Sierpinski triangle by subdivision or chaos game; export as PNG.
Koch Snowflake Generator
Koch snowflake and anti-snowflake to any depth; export as PNG.
Random Walk Art
Walkers take thousands of random steps; the path becomes the picture.
Mandelbrot Explorer
Click to zoom into the Mandelbrot set; export the view at 4K.
Flow Field Generator
Particles traced through a Perlin noise field; the classic generative-art look.