Report Tool or Give Us Suggestions

L-system Generator

Generate and visualize Lindenmayer systems (L-systems) online. Load presets like the Koch Snowflake, Dragon Curve, or custom fractals with real-time canvas rendering and SVG vector export.

L ading . . .

L-System (Lindenmayer System) Generator

An L-system or Lindenmayer system is a parallel rewriting system and a type of formal grammar. Invented in 1968 by Hungarian theoretical biologist and botanist Aristid Lindenmayer, L-systems were originally introduced to model the growth processes of plant development, algae, and branching structures. Today, they are widely celebrated for their ability to generate intricate, self-similar fractals and geometric curves using simple rules.

How Do Lindenmayer Systems Work?

An L-system is recursively defined by a triple:

L = (V, ω, P)

Where:

  • V (Alphabet): A set of symbols containing both variables (symbols that can be replaced) and constants (symbols that remain unchanged).
  • ω (Axiom / Initiator): A starting string of symbols from V that defines the initial state of the system.
  • P (Production Rules): A set of rewriting rules that define how variables are replaced by other strings of symbols in each generation.

In every iteration (or generation), the generator performs a parallel rewriting process. Unlike standard computer science grammars where rules are applied sequentially, in an L-system, every variable in the string is replaced simultaneously. This parallel execution perfectly mimics natural cellular division and growth processes.

Turtle Graphics Translation

To visualize an L-system, the final expanded string is interpreted as a sequence of drawing instructions for a virtual "turtle" moving on a two-dimensional screen. The turtle holds a pen and moves in response to specific grammar commands:

Command Action / Description
F Move forward by the segment step size and draw a line.
G Move forward by the segment step size and draw a line (equivalent to F).
f Move forward by the segment step size without drawing a line (pen up).
g Move forward by the segment step size without drawing a line (pen up).
+ Turn right (clockwise) by the specified angle in degrees.
- Turn left (counter-clockwise) by the specified angle in degrees.
[ Branch Start: Push the current state (position X, Y and direction angle) onto a memory stack. Essential for drawing trees and plant systems.
] Branch End: Pop the saved state from the memory stack and restore the turtle to that position and angle (without drawing a line).
| Turn around (rotate 180 degrees) to face the opposite direction.

Step-by-Step Example: The Koch Snowflake

Let's examine how the classic Koch Snowflake fractal is constructed:

  1. Axiom (ω): $$F--F--F$$ (This represents three line segments forming an equilateral triangle pointing downwards, rotated by 120° twice via the $--$ command).
  2. Rule (P): $$F \to F+F--F+F$$ (This rule instructs the computer: "Whenever you see a line segment F, replace it with a straight line, turn right, straight line, turn left twice, straight line, turn right, straight line". This replaces a flat line segment with a triangular peak).
  3. Generation 1: The rule is applied to all three $F$ characters simultaneously, yielding:
    (F+F--F+F)--(F+F--F+F)--(F+F--F+F)
  4. Generation 2: The rule is applied recursively to all new $F$ characters, adding a smaller triangular peak to each of the 12 new segments.

Classic L-System Configurations Reference

Below is a quick reference table of popular fractals that you can copy and paste or load directly using the presets dropdown:

Fractal Name Axiom Rules Angle Optimal Iters
Dragon Curve FX X=X+YF+
Y=-FX-Y
90° 9 - 11
Sierpinski Gasket F-G-G F=F-G+F+G-F
G=GG
120° 5 - 6
Hilbert Curve A A=-BF+AFA+FB-
B=+AF-BFB-FA+
90° 4 - 6
Barnsley Fractal Plant X X=F+[[X]-X]-F[-FX]+X
F=FF
25° 4 - 5

Frequently Asked Questions (FAQs)

Frequently Asked Questions

What is a Lindenmayer system (L-system)?

An L-system is a mathematical formal grammar developed by biologist Aristid Lindenmayer in 1968. It consists of a starting sequence of characters (an axiom) and a set of production rules that recursively expand each character in parallel in subsequent iterations. When translated via turtle graphics, L-systems produce beautiful natural shapes and fractals.

How do variables like X, Y, A, and B behave in turtle graphics?

In classic L-system turtle graphics, characters like F and G represent commands to move forward and draw a line, while constants (+, -, [, ]) control turning and branching. Other characters, like X, Y, A, and B, act as purely logical variables. They expand according to the production rules during the rewriting phase, but are ignored by the drawing turtle during the rendering phase.

What are bracketed L-systems and why are they used to model plants?

Bracketed L-systems introduce square brackets `[` and `]` into the grammar. The open bracket `[` saves the turtle's current position and heading (pushes to a stack), and the closing bracket `]` pops the position and restores the turtle back to that saved state. This simple branching mechanism is essential to model natural plants, twigs, ferns, and trees, allowing multiple twigs to sprout from a single branch.

Can I export the L-systems I create here?

Yes! This tool provides two powerful export methods. You can export as a high-resolution PNG image, suitable for presentations or digital backgrounds. You can also export as a highly flexible vector SVG file, which renders the exact drawing path as vector nodes, perfect for digital artists, Cricut cutters, and graphic designs in Illustrator.

Why does the generator cap high iterations?

The number of line segments generated by L-systems grows exponentially. For example, a 12-iteration Dragon Curve contains thousands of coordinates. Capping the total character length at 300,000 ensures that the rewriting process and canvas rendering run completely in real time without causing memory issues or locking up your browser.

logo OnlineMiniTools

OnlineMiniTools.com is your ultimate destination for a wide range of web-based tools, all available for free.

Feel free to reach out with any suggestions or improvements for any tool at admin@onlineminitools.com. We value your feedback and are continuously striving to enhance the tool's functionality.

© 2026 OnlineMiniTools . All rights reserved.

Hosted on Hostinger

v1.10.0