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.

Options
Grammar Options
Draw these symbols.
Skip these symbols.
Starting axiom.
Rewrite rule 1.
Rewrite rule 2.
Rewrite rule 3.
Rewrite rule 4.
Rewrite rule 5.
Curve Options
Curve width.
Curve height.
How many iterations to perform?
Angle of rotation.
Starting direction of movement.
Thickness of a curve.
Padding around the image.
Colors
Background color.
Curve color.
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

  1. Enter the axiom (starting string).
  2. Define production rules (e.g., A→AB, B→A).
  3. Specify the number of iterations.
  4. 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.

Input
Order: 0
Size: 100
Angle: 90
Output
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.

L-Systems

Lindenmayer systems (L-systems) are parallel rewriting systems. Starting from an axiom string, all characters are simultaneously replaced according to production rules. Axiom: A, Rule: A→AB, B→A. Iterations: A → AB → ABA → ABAAB → ABAABABA. The result models biological growth patterns.

Applications

L-systems model plant morphology (branching, leaf arrangement), generate fractal curves (Koch snowflake, Sierpinski triangle, dragon curve), and create procedural content in computer graphics. Combined with turtle graphics interpretation, they produce stunning visual patterns from simple rules.

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.