L-System Generator
Generate strings from L-system (Lindenmayer system) rules — a formal grammar used to model plant growth, fractals, and self-similar structures. Define axioms and production rules to produce complex strings.
Grammar Options
Curve Options
Colors
Output
What It Does
Generate strings from L-system (Lindenmayer system) rules — a formal grammar used to model plant growth, fractals, and self-similar structures. Define axioms and production rules to produce complex strings.
How It Works
L-System Generator applies a focused transformation to the input so you can compare the before and after without writing a custom script for a one-off task.
Unexpected output usually comes from one of three places: the wrong unit of transformation, hidden formatting in the source, or an option that changes the rule being applied.
All processing happens in your browser, so your input stays on your device during the transformation.
Common Use Cases
- Model plant branching structures
- Generate fractal curve descriptions (Koch, Sierpinski, dragon)
- Study formal grammars and string rewriting
- Create procedural generation rules for games and art
- Educational exploration of grammar-based systems
How to Use
- Enter the axiom (starting string).
- Define production rules (e.g., A→AB, B→A).
- Specify the number of iterations.
- Click Generate to see the result.
Features
- Custom axiom and rule definitions
- Multiple production rules
- Iteration count control
- String length tracking per iteration
- Turtle graphics interpretation hints
Examples
Below is a representative input and output so you can see the transformation clearly.
Order: 0 Size: 100 Angle: 90
Path: (0,0) (100,0)
Edge Cases
- Very large inputs can still stress the browser, especially when the tool is working across many numbers. Split huge jobs into smaller batches if the page becomes sluggish.
- Empty or whitespace-only input is technically valid but may produce unchanged output, which can look like a failure at first glance.
- If the output looks wrong, compare the exact input and option values first, because L-System Generator should be repeatable with the same settings.
Troubleshooting
- Unexpected output often means the input is being split or interpreted at the wrong unit. For L-System Generator, that unit is usually numbers.
- If a previous run looked different, check for hidden whitespace, changed separators, or a setting that was toggled accidentally.
- If nothing changes, confirm that the input actually contains the pattern or structure this tool operates on.
- If the page feels slow, reduce the input size and test a smaller sample first.
Tips
L-systems grow exponentially. Even simple rules like F→FF double the string length each iteration. 10 iterations of this rule produces a string of length 1024.
Frequently Asked Questions
What is an axiom?
The starting string before any rules are applied.
What are production rules?
Substitution rules applied simultaneously to all matching characters. A→AB means every A is replaced by AB in each iteration.
How fast do L-systems grow?
Exponentially in most cases. Track the string length per iteration to avoid generating unmanageably large strings.
Can I visualize the output?
L-system strings are often interpreted as turtle graphics commands: F=forward, +=turn right, -=turn left, [=save position, ]=restore position.
What famous fractals use L-systems?
Koch snowflake, Sierpinski triangle, dragon curve, Hilbert curve, and many plant models.
What are context-sensitive L-systems?
Advanced L-systems where rules depend on neighboring characters. This tool supports context-free rules.