L-System Fractal Generator
Generate beautiful fractals from Lindenmayer-system rules. Pick a classic preset (Koch snowflake, Sierpinski, dragon curve, fractal tree, plant) or write your own axiom, production rules, and turtle angle — the tool expands the string, walks the turtle, and renders a depth-colored SVG with animated drawing.
Your ad blocker is preventing us from showing ads
MiniWebtool is free because of ads. If this tool helped you, please support us by going Premium (ad‑free + faster tools), or allowlist MiniWebtool.com and reload.
- Allow ads for MiniWebtool.com, then reload
- Or upgrade to Premium (ad‑free)
About L-System Fractal Generator
The L-System Fractal Generator turns Lindenmayer-system grammars into beautiful, depth-colored, animated SVG fractals. Pick a preset — Koch snowflake, Sierpinski triangle, Heighway dragon, Hilbert curve, fractal plant, tree, or bush — or write your own axiom and production rules and watch the string explode into a self-similar shape. The tool expands the string server-side, walks a virtual turtle through every symbol, and renders the result as scalable SVG you can download, edit, or paste into your slides.
What Is an L-System?
An L-system, or Lindenmayer system, is a parallel string-rewriting grammar invented in 1968 by Hungarian biologist Aristid Lindenmayer to mathematically model the growth of plants and microorganisms. It has three ingredients: an axiom (a starting string of one or more symbols), one or more production rules (each rule maps a single symbol to a replacement string), and an interpretation (here, turtle graphics — a virtual pen that obeys forward, turn-left, turn-right, push, and pop commands).
To run the system, you start with the axiom and apply the rules in parallel — every symbol is replaced at once, then the next iteration begins. After a handful of iterations the string has become enormous and unmistakably fractal. When you hand that string to the turtle, the self-similar drawing appears.
Turtle Symbols at a Glance
| Symbol | What the turtle does |
|---|---|
| F, G | Move forward one step and draw a line. |
| f | Move forward one step without drawing. |
| + | Turn left by the angle you specified (e.g. 25°, 60°, 90°). |
| - | Turn right by the angle. |
| | | Flip the heading by 180°. |
| [ | Push the current position and heading on a stack — used to start a branch. |
| ] | Pop position and heading from the stack — return to the branch point. |
| X, Y, A, … | Other letters: pure rewrite symbols. They affect the next iteration but draw nothing themselves. |
What Makes This L-System Generator Different
How the Rewriting Works (Worked Example)
Take the Koch curve with axiom F and rule F → F+F-F-F+F, with the turtle angle set to 90°. Here is how the string evolves:
- Iteration 0:
F— 1 character. - Iteration 1:
F+F-F-F+F— 9 characters. The single F has become a square bump. - Iteration 2:
F+F-F-F+F + F+F-F-F+F - F+F-F-F+F - F+F-F-F+F + F+F-F-F+F— 49 characters. Every F from iteration 1 has itself been replaced by F+F-F-F+F. - Iteration 3: 249 characters. Iteration 4: 1,249 characters. Iteration 5: 6,249.
The growth is geometric: every iteration multiplies the length by 5 (the length of the replacement string). After 5 iterations the turtle has thousands of commands to follow and the result is recognizably the Koch fractal — a coastline-like curve whose fractal dimension is log(4)/log(3) ≈ 1.26.
How Brackets Build Plants
Without the bracket symbols [ and ], every L-system is a single unbroken curve. The brackets unlock branching: when the turtle hits [ it pushes its current position and heading onto a stack, draws the branch inside the brackets, then on ] pops back to where it was. The rule F → F[+F][-F]F says "every forward stroke becomes a stroke, a left branch, a right branch, and a continuing stroke" — a recipe for a tree.
The fractal plant preset shows this beautifully. Its rule X = F+[[X]-X]-F[-FX]+X uses doubled brackets to encode branches-within-branches. After 5 iterations the resulting string contains 11,000+ symbols and roughly 1,000+ bracket pairs — the turtle dutifully pushes and pops its way through, drawing a fern.
Where L-Systems Are Used
- Procedural plant generation: the SpeedTree and Houdini ecosystems use L-systems (and their stochastic, parametric, and context-sensitive extensions) to grow forests, jungles, and crop fields for film and games.
- Architectural and urban modeling: rule-based grammars descended from L-systems generate building facades, street networks, and entire procedural cities.
- Biology and morphology: the original use case — modeling the development of cells in algae, branching in plants, and the structure of corals and crystals.
- Computer graphics and demoscene art: compact descriptions of complex fractal curves with very small file sizes — a 30-byte rule can produce a megapixel image.
- Mathematics education: the canonical example of a context-free parallel grammar; an intuitive bridge from formal languages to fractal geometry.
- Generative music and choreography: the same rewriting machinery, applied to musical phrases or dance moves, produces structured-yet-organic compositions.
Designing Your Own L-System
A few rules of thumb that consistently produce good-looking fractals:
- Start small. Three iterations of a new rule is enough to see the structure. Increase only after you know the shape grows the way you want.
- Pick angles that divide 360° evenly (60°, 72°, 90°, 120°) for curves. For plants, angles between 18° and 30° produce natural-looking branching.
- Use non-drawing symbols like X to control structure. The rule
F → FFjust doubles every stroke, butX → F+X[-X]with axiomXcreates a branching shape — F draws the visible line, X controls the branching pattern. - Balance your brackets. Every
[must have a matching]. The tool tolerates unbalanced brackets at draw time, but you will get unexpected jumps. - Watch the growth rate. If your rule replaces F with five symbols, each iteration multiplies the string by 5. Six iterations of
F → FF+F-F+Falready overflows most renderers.
Stochastic and Parametric Extensions
The deterministic L-system in this tool is the simplest variant. Real-world plant modelers use richer grammars: stochastic L-systems assign probabilities to multiple rules for the same symbol, so each plant is slightly different. Parametric L-systems attach numerical values to symbols (a branch's length or thickness) and let rules read and modify them. Context-sensitive L-systems let a rule fire only when its symbol has specific neighbors. Each of these turns a static fractal into a system that can grow, react, and age.
Common Misconceptions
- "More iterations always look better": false. Beyond five or six iterations the strokes overlap and detail is lost. The optimal iteration depth depends on the rule and the display resolution.
- "L-systems can only draw plants": they describe any self-similar curve. The Hilbert curve, the dragon curve, the Sierpinski gasket — all L-systems.
- "Brackets are required": no. Single-stroke curves like Koch, dragon, and Lévy use no brackets. Brackets are needed only when you want branching.
- "All fractals have the same fractal dimension": false. Koch's dimension is ≈1.26, the dragon's is 2, the Sierpinski's is ≈1.58, the Hilbert curve's approaches 2 — each rule has its own dimension determined by how the string grows vs. how far the turtle moves.
Frequently Asked Questions
What is an L-system?
A Lindenmayer system, or L-system, is a parallel string-rewriting grammar invented in 1968 by biologist Aristid Lindenmayer to model plant growth. It starts with an axiom (a short string), repeatedly applies production rules that replace single symbols with longer strings, and then interprets the final string as turtle-graphics commands. The result is a self-similar fractal.
What do the symbols mean?
F and G are drawing strokes (the turtle moves forward and draws a line). f is a silent move (forward without drawing). + turns the turtle left by the angle you specified, - turns it right, and | flips it 180 degrees. [ pushes the turtle's position and heading onto a stack, ] pops it back. All other letters (X, Y, A, B, …) are rewrite-only — they affect the next iteration but do not draw.
Why are L-systems good at modeling plants?
The bracket symbols [ ] let the turtle remember and restore its position, so a single rule can branch. A rule like F = F[+F][-F]F draws a stem, branches off two ways, then continues — exactly how a plant grows. With slightly different rules and angles, the same engine generates ferns, bushes, trees, seaweed, and roots.
What is the difference between F and X in the rules?
F is a drawing symbol (when the turtle sees F it draws a line) AND a rewrite symbol (rules may match F on the left). X is a pure rewrite symbol — when the turtle sees X during drawing, it does nothing. X is useful when you want a symbol that controls structure without being drawn.
How many iterations should I use?
For most presets, 4-6 iterations produce a recognizable fractal. The string length grows exponentially, so going from 6 to 7 iterations may multiply the work by 3-5 times. The tool caps iterations at 8 and the rewritten string at 250,000 characters to keep rendering responsive.
What controls the depth-based coloring?
Every [ pushes the turtle into a deeper bracket level; every ] pops back. The deepest level reached is the maximum depth. Choose "Depth gradient" to color every stroke by its bracket level — perfect for plants, where the trunk and branches naturally fall into different depths.
How does the starting angle work?
The starting angle is the direction the turtle is facing at the very first step. 0° means east (rightward) — used by most curves. 90° means north (upward) — used by plants and trees so they grow toward the top of the canvas. Try changing the start angle on any preset to rotate the entire figure.
Can I download the fractal?
Yes. Download as SVG for crisp scaling in print, presentations and laser cutters, or as PNG for sharing on chat and social. The Copy button copies the full L-system definition (axiom, rules, angle, iterations) so you can paste it into your notes or another tool.
What is the maximum complexity?
Up to 8 rewrite iterations, 250,000 characters in the expanded string, 60,000 drawing segments, and 12 production rules. These caps keep the SVG light enough to render and download smoothly. For larger meshes, consider a desktop L-system tool such as cgkit or Houdini.
What if my brackets are unbalanced?
An unbalanced ] (without a matching [) is silently ignored — the turtle stays where it is. An unbalanced [ (no closing ]) means the turtle never pops, so it keeps drawing forward without ever returning to a branch point. The tool always finishes drawing, but the result may not look like what you intended. Match every [ with a ].
What is a turtle-graphics interpreter?
It is a virtual pen that obeys movement commands from a string. The name comes from the Logo programming language. The turtle has a position and a heading (the direction it faces). Each F moves it forward one step in its current heading; + and - rotate the heading. The turtle is what turns a flat string into a 2D drawing.
Why does my fractal look squished?
The tool auto-fits the drawing to the canvas while preserving aspect ratio, so the figure scales but does not distort. If a fractal looks visually unbalanced, it may be the rule itself — for example, the dragon curve is wider than it is tall, which is correct. Increase iterations to see the shape converge.
Reference this content, page, or tool as:
"L-System Fractal Generator" at https://MiniWebtool.com// from MiniWebtool, https://MiniWebtool.com/
by miniwebtool team. Updated: 2026-05-20