L-System Visualizer

Type an axiom, list rewrite rules, then set the turn angle and depth. Every symbol expands in parallel on each pass, and the turtle walks the finished string once. The drawing scales itself to fit the frame.

L-system drawing workbench

String length 0Segments drawn 0Depth 4
Grammar
Starting string before any rewrite.
One rule per line. Use F=FF or F -> FF. Single-letter heads only.
Geometry
Initial turtle heading in degrees, measured counterclockwise from east.
Starter shapes
Expanded string (debug)

One extra iteration often multiplies symbol count far more than newcomers expect. If the page stutters, drop depth first, then shorten rules.

Heads up. This page applies classic turtle semantics on a single canvas. Brackets push position plus heading, pop restores them. Symbols outside the turtle alphabet are ignored for motion but still ride through rewrites.

When the string grows faster than patience

Lindenmayer systems rewrite every symbol in the current string at once. Two short rules plus six iterations routinely cross tens of thousands of characters. The visualizer still draws at that size, though frame time climbs with it.

We cap depth at eight so a stray keystroke does not freeze the tab. For print work you would still rebuild the figure as vector output somewhere else. The goal here is fast feedback while you learn how axiom choice steers the silhouette.

Motion alphabet (this tool)

F or G
Step forward while drawing a segment.
f
Step forward without ink (pen up).
+
Rotate left by the turn angle you set.
-
Rotate right by the same angle.
[
Save position plus heading.
]
Restore the last saved state.

Any other single character (for example X or Y) is a structural placeholder you rewrite until only motion symbols remain, or until you stop iterating.

Reading the three numbers under the canvas

String length counts every character after expansion, placeholders included. Segments drawn counts only F and G, so it tells you how many lines the turtle actually inked. Depth mirrors the iteration control.

The gap between the first two numbers is the useful signal. A plant grammar at depth 5 might report 12,000 characters and 4,000 segments, which means two thirds of the work went into bookkeeping symbols. When segments sit near zero but string length is large, your rules never produced a motion symbol and the frame stays blank.

Rewriting without hand-waving

You type an axiom, list productions with = or an ASCII arrow, then pick iterations. The engine expands left to right, substituting each head symbol with its body or leaving it unchanged when no rule exists. After expansion the turtle walks the final string once.

Auto-fit measures every vertex the turtle visits, then scales and centers the polyline inside the frame. Shrinking step length does not shrink the overall shape forever. It changes local detail density while bounds tracking keeps the whole figure visible.

Preset cheat sheet

TileAxiomAngleNotes
KochF60°Three-fold snowflake spine.
SierpinskiF-G-G120°Two symbols, two productions.
PlantX25°Heavy brackets, organic feel.
TreeF25.7°Symmetric branching.
FernX25°Same rules as plant, deeper run and shorter step.
DragonFX90°Uses helper symbols X and Y.

Brackets behave like a stack, not decoration

Every opening bracket freezes the turtle where it stands. The interpreter pushes x, y, heading. A closing bracket teleports back without drawing a connecting segment. One stem forks, draws a twig, returns, draws another twig.

If your plant looks like a scribble, count brackets. An unbalanced line usually means a missing closer or an extra opener on one production. The turtle never guesses intent. It executes the expanded string in order, and an unmatched closer is simply skipped.

Four mistakes that produce an empty frame

Same family, different front door

If you want grammar editing without the scaling stage, open the L-System Fractal Generator. Prefer classic snowflake geometry with dedicated sliders? Use the Koch Snowflake Generator. Branching silhouettes without writing productions first appear in the Fractal Tree Generator.

What this page refuses to do

There is no stochastic rule picker, no 3D turtle, no image export. Stochastic L-systems need a random seed per run and a weighted rule table. A 3D turtle needs a second rotation axis and a pitch command set. You also will not find file upload: the grammar lives in the textarea only.

Processing stays in your tab. Nothing reaches a server, and clearing the canvas is enough if someone else uses the machine. The expanded string panel is optional, useful mainly for students tracing how fast symbol count climbs.

Visualizer questions we see often

Short answers tied to this turtle implementation.

Why does my curve vanish after I change heading?

Auto-fit recomputes bounds from every drawn vertex, so rotating the heading rotates the whole polyline rather than cropping it. A truly empty frame points at the grammar instead: if the rules never emit F or G, the segment counter reads zero and there is nothing to scale. Add a motion symbol or raise iterations so placeholders unfold.

Do spaces inside rules matter?

Leading and trailing spaces on each line are trimmed. Spaces inside the replacement string count as literal characters, which usually breaks single-letter turtle commands. Keep productions tight unless you intentionally embed blanks.

Why is dragon slower than Koch at the same iteration count?

Dragon-style axioms mix two non-drawing symbols before the string fills with turns and steps. Length grows faster than intuitive estimates, so the turtle executes more commands per depth step. Drop depth or raise step length before blaming hardware.

Can I write two rules for the same symbol?

No. Rules are stored in a plain map keyed by the head character, so a second line for the same symbol overwrites the first. Deterministic output is the trade: you get the same picture every draw, at the cost of the randomness that stochastic L-systems rely on.

Does Toolexe store my grammar?

No server round trip runs here. The script reads your fields, expands the string in memory, paints the canvas, and stops. Refreshing the page clears everything unless your browser restores form fields.