Overview
Introduction
L-systems were introduced by biologist Aristid Lindenmayer in 1968 to model how plants grow, and it turned out the same simple idea, rewrite a string, then draw it with a turtle, also produces some of the most recognizable fractal curves in mathematics.
This tool exposes the whole mechanism directly: you write the axiom and the production rules yourself, set a turn angle and iteration count, and watch the resulting curve render as an SVG you can download.
What Is L-system Generator?
A general-purpose L-system interpreter and renderer. Unlike the other curve tools in this category, which each hard-code one famous curve's axiom and rules, this one lets you define your own.
It ships four one-click presets, the Koch snowflake, the dragon curve, the Sierpinski arrowhead, and a plant-like branching structure, so you can see working examples before experimenting with your own axiom and rules.
How L-system Generator Works
Your axiom string is expanded for the chosen number of iterations: on every round, each character in the current string is replaced according to the matching production rule (a letter with no rule just carries over unchanged).
The fully expanded string is then interpreted as turtle-graphics instructions: F or G moves forward and draws a segment, plus and minus turn the turtle left or right by your angle, and square brackets save and restore the turtle's state for branching.
The resulting line segments are normalized to fit the SVG viewbox and rendered as a single path, which you can export as SVG or a rasterized PNG.
When To Use L-system Generator
Use it to explore how a production rule and turn angle translate into a shape, whether you're learning about L-systems for the first time or designing your own fractal curve.
It's also useful for reproducing a specific published L-system, such as a plant or space-filling curve you found in a paper or textbook, by typing in its documented axiom, rules, and angle directly.
If you just want one specific, already-named curve (Hilbert, dragon, twindragon, terdragon), the dedicated single-purpose tools for those are quicker since the axiom and rules are pre-filled and validated for you.
Often used alongside Generate a Hilbert Curve, Generate a Dragon Curve and Generate a Heighway Triangle.
Features
Advantages
- Full control over axiom, production rules, and turn angle, not limited to a fixed catalog of preset curves.
- Four working presets to start from, so the correct rule syntax is easy to copy and adapt.
- Instant SVG and PNG export of whatever curve you generate.
Limitations
- Iteration count is capped (10 for custom input) to keep the expanded string and the resulting render from overwhelming the browser.
- Only the standard turtle alphabet is supported, F/G to draw, f to move without drawing, plus/minus to turn, and square brackets to branch, so context-sensitive or stochastic L-system variants aren't representable.
Examples
Best Practices & Notes
Best Practices
- Start from a preset and change one value at a time, angle, then a single rule, so you can see exactly how each change reshapes the curve.
- Increase the iteration count gradually; a rule that looks fine at 4 iterations can produce an enormous, slow-to-render string at 10.
Developer Notes
The expansion step (`expandLSystem`) rewrites the axiom character by character for the requested number of iterations, capped at a 2,000,000-character safety limit, and the draw step (`drawLSystem`) walks the expanded string interpreting F/G as forward-and-draw, plus/minus as turns by the configured angle, and square brackets as a position/heading stack for branching; the built-in presets include the Koch snowflake (axiom F++F++F, rule F=F-F++F-F, angle 60) and the dragon curve (axiom FX, rules X=X+YF+ and Y=-FX-Y, angle 90).
L-system Generator Use Cases
- Learning how L-systems translate string rewriting into geometric curves
- Prototyping a custom fractal or plant-like branching pattern before implementing it elsewhere
- Reproducing a specific published L-system's axiom, rules, and angle for a report or presentation
Common Mistakes
- Writing a rule that never introduces an F or G, which produces a blank canvas since nothing is ever drawn.
- Forgetting to balance square brackets in a branching rule, which silently truncates or distorts the branch structure rather than raising an error.
Tips
- If a curve looks tangled rather than self-similar, try lowering the iteration count first, some shapes only reveal their structure clearly at 3 or 4 iterations before becoming too dense to read.
- Use the Sierpinski arrowhead or plant-branching presets as a starting point for exploring non-dragon, non-Koch L-systems.