Koch Curve Generator
Take a line, replace its middle third with two sides of an equilateral triangle, and repeat. Every step multiplies the segment count by four and the length by four thirds — so the curve's length grows without limit while it stays inside a finite area. That contradiction is what a fractional dimension measures, and here it is exactly log 4 over log 3, or about 1.262.
What this generator does
Recursively replaces each segment with four segments of a third the length, either along one line or around a closed triangle. The segment count, the length as a multiple of the original, and the dimension are all reported.
How to use this tool
- Choose the depth, from a straight line up to five levels.
- Switch between the open curve and the closed snowflake.
- Read the segment count and the length factor.
- Notice the length growing while the figure stays in the same box.
Understanding the controls
- Depth
- From 0, which is the plain starting figure, up to 5. Depth 5 already has over a thousand segments per side.
- Closed snowflake
- On, the construction runs around a triangle and closes into the snowflake. Off, it is a single open curve, which makes the length growth easier to see.
Common use cases
- Showing how an infinite length fits in a finite area
- Teaching fractal dimension with a figure where the numbers are exact
- Generating Koch outlines for a diagram or a cutting file
- Comparing the open curve against the closed snowflake
- Illustrating self-similarity at every scale
How this generator works
Each segment is split into thirds and the middle third replaced by two sides of an equilateral triangle, pointing outward at sixty degrees. The check confirms the segment count is exactly four to the power of the depth, the length factor exactly four-thirds to that power, and — the real test of self-similarity — that every segment came out the same length.
Randomness and fairness
Nothing here is random at all: a depth and a shape choice determine the figure completely, which is why there is no seed.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Depth stops at 5, where the figure already has thousands of segments and further detail is below a pixel.
- Only the classic outward construction; inward variants and other generators are not offered.
- The figure is drawn as a polyline rather than filled.
- Coordinates are rounded to two decimal places for display, so the segment lengths agree to that precision rather than exactly.
- Figures are recomputed from the digit rule on each visit rather than kept.
Privacy and your data
The curve is computed in your browser. Nothing about it is transmitted or kept.
Related generators
- L-System GeneratorWrite your own rewriting rules — or take one of five classics — and watch the string grow and turn into a path, with the size worked out before anything is drawn.
- Sierpinski Fractal GeneratorThe Sierpinski triangle and carpet computed by a digit rule rather than recursion, with the exact cell count at every depth.
- Random Polygon GeneratorSimple polygons that never cross themselves, with the shoelace area, the perimeter and a convexity check.
- Geometric Pattern GeneratorBuilds a tiled pattern under a symmetry rule and hands you the SVG — mirrored, half-turn or quarter-turn.