Turtle Graphics

Draw with turtle graphics in your browser: a small turtle carries a pen, and you steer it with short Logo-style commands such as fd 100 (forward 100 steps), rt 90 (turn right 90°) and repeat 4 [ … ]. Type a program, or start from one of the examples (polygons, stars, spirals, a ring of squares, a flower made of arcs), and the drawing updates as you type. Change the pen colour and width inside the program, lift the pen to make gaps, and use repcount to grow a spiral step by step. Print it fitted to the page or at real size (1 step = a length you choose), or download an SVG, a 300 DPI PNG or every line as CSV. Your program is read by our own small parser and never runs as code; nothing is uploaded.

100% private — everything runs in your browser. Everything runs in your browser; nothing is uploaded.

100% private — runs in your browser

Print at 100% (Actual size). Real size prints on one sheet when the drawing fits; the check bar in the footer lets you confirm the scale. The SVG holds the drawing at the printed size. The CSV lists every line the turtle drew (start, end, colour, width).

Turtle program

Example: repeat 5 [fd 150 rt 144]. Inside a repeat, repcount is 1, 2, 3 … so fd repcount * 2 grows each time. Colours: black, red, blue, green, orange, purple, teal, brown, grey, pink, gold, navy or #rrggbb.

Look

Page

Runs in your browser with our own code: nothing you type is uploaded or saved. Your program is read by our own small parser (it never runs as JavaScript), and every line on the page comes from that interpreter. You may use what you make here, including commercially, with no credit needed.

How to draw with turtle graphics

  1. Pick an example program, or type your own in the box.
  2. Use fd / bk to move, lt / rt to turn, pu / pd to lift and lower the pen, and repeat N [ … ] to loop.
  3. Set the pen colour and line width, or change them inside the program with color and width.
  4. Choose Fitted to one page, or Real size and how long one step is.
  5. Download the PDF and print at 100% (Actual size), or the SVG, PNG or CSV.

What you can use it for

  • First coding lessons: loops, angles and polygons
  • Checking what a turtle program draws before running it elsewhere
  • Star, spiral and rosette line art
  • Plotter and laser line art from the SVG
  • Worksheets on exterior angles (the turtle turns 360° in total round a polygon)
  • Geometry art posters

The 15 example programs

ExampleProgram (first line)Lines drawnCommands runBack at the start
Square: repeat 4 [fd 100 rt 90]repeat 4 [fd 100 rt 90]49yes
Trianglerepeat 3 [fd 120 rt 120]37yes
Hexagonrepeat 6 [fd 60 rt 60]613yes
Circle: repeat 360 [fd 1 rt 1]repeat 360 [fd 1 rt 1]360721yes
Five-point starrepeat 5 [fd 150 rt 144]511yes
Nine-point starrepeat 9 [fd 150 rt 160]919yes
Square spiral (repcount)repeat 120 [fd repcount * 2 rt 90]120241169.7 steps away
Twisted spiral: turn 91°repeat 200 [fd repcount rt 91]200401141 steps away
Ring of 36 squaresrepeat 36 [repeat 4 [fd 80 rt 90] rt 10]144361yes
Flower of 12 petals (arcs)repeat 12 [ …1,4402,953yes
Sun: 36 raysrepeat 36 [fd 80 bk 80 rt 10] …10818620 steps away
Dashed circle (pen up and down)repeat 36 [pd fd 5 pu fd 5 rt 10]36181yes
Five pentagonsrepeat 5 [repeat 5 [fd 80 rt 72] rt 72]2561yes
Two stars in two colours and widthscolor red width 0.4 …1027yes
Real size: 100 mm square (1 step = 1 mm)repeat 4 [fd 100 rt 90]49yes

Counts are worked out by the tool when it runs each program.

The commands

CommandShort formWhat it does
forward Nfd NMove N steps the way the turtle faces, drawing if the pen is down
back Nbk NMove N steps backwards
left A / right Alt A / rt ATurn A degrees counter-clockwise / clockwise
setheading Aseth AFace compass heading A (0 = up, 90 = right)
penup / pendownpu / pdLift or lower the pen
repeat N [ … ]Run the commands in brackets N times; repcount counts 1, 2, 3 …
color NAMEcolour NAMEChange the pen colour (a name or #rrggbb)
width WChange the line width to W mm (0.05 to 2)

The turtle starts in the middle facing up. Case does not matter, and a ; starts a comment to the end of the line.

Regular polygons: repeat N [fd 10 rt 360 / N]

Sides NTurn each timeTotal length (steps)Back at the startRadius of the corners (steps)
3120°30yes5.7735
490°40yes7.0711
572°50yes8.5065
660°60yes10
845°80yes13.0656
1230°120yes19.3185
3610°360yes57.3686
904°900yes143.2685
3601°3600yes572.9651

The radius is measured from the tool’s own drawing; it equals 10 / (2 sin(180° / N)) to 0.000000001, so with more sides the polygon approaches a circle.

Stars: repeat N [fd 100 rt A]

Points NTurn ATotal turnCloses
5144°720°yes
7154.2857°1080°yes
8135°1080°yes
9160°1440°yes
12150°1800°yes
572°360°yes
6144°864°no, 100 steps away

A star closes when the total turn N × A is a whole number of full turns (360°, 720° …).

What prints

DownloadWhat is in it
PDFThe drawing fitted to one page or at real size, vector lines in the program’s colours and widths, with the counts and a check bar
PNG 300 DPIThe same sheet as a picture
SVGThe drawing at the printed size, one path per colour and width
CSVEvery line: start, end, colour, width

For a cutter that needs DXF, use SVG to DXF; to edit a path by hand, use the SVG Path Editor.

Which tool to use

You wantUse
Type turtle commands and print the drawingTurtle Graphics (this page)
Fractal trees and curves from L-system rulesFractal Generator
Rolling-circle curve artSpirograph Generator, Epicycloid, Hypocycloid
Any drawing traced by turning circlesFourier Epicycles

Other tools: the Fractal Generator draws L-system fractals from ready-made rules, the Spirograph Generator draws rolling-circle art and Graph Paper prints grids for planning a program by hand.

More free tools

Maths art, curves and printables?

Drawing and print tools that run privately in your browser, with no sign-up and no watermark.

See all free tools →

Frequently asked questions

What is turtle graphics?

Drawing by steering a pen-carrying turtle with commands relative to where it is and which way it faces, such as move forward 10 or turn left 90 degrees, instead of giving x and y coordinates. It is best known from the Logo programming language: Logo was designed in 1967 by Wally Feurzeig, Seymour Papert and Cynthia Solomon, and Papert added turtle graphics to it in the late 1960s (Wikipedia, Logo (programming language) and Turtle graphics, read 13 November 2026).

Is this Logo?

No. It is our own small turtle language in the Logo style: the movement, turning, pen, repeat, colour and width commands only, with no procedures or variables apart from repcount. Many short Logo drawing programs made of these commands run here unchanged.

Which commands can I use?

fd or forward, bk or back, lt or left, rt or right (angles in degrees), seth (compass heading: 0 = up, 90 = right), pu or penup, pd or pendown, repeat N [ … ], color or colour with a name or #rrggbb, and width in mm (0.05 to 2). Numbers can be sums such as repcount * 2 + 5 with brackets. A ; starts a comment. Colour names: black, red, blue, green, orange, purple, teal, brown, grey, pink, gold, navy.

What is repcount?

Inside a repeat, repcount is 1 on the first time round, 2 on the second, and so on; in nested repeats it belongs to the innermost one. So repeat 120 [fd repcount * 2 rt 90] draws a square spiral whose sides grow 2, 4, 6 … steps.

Is it safe to paste a program?

Yes. The program is read by our own parser, which only knows the commands above: it never runs your text as JavaScript, and anything else (a stray symbol, an unknown word) stops with an error that names the line. Our tests feed it script tags, JavaScript calls and other odd input and check that each one is refused.

Are there limits?

Yes, so a runaway loop cannot freeze the page: programs up to 10,000 characters, repeat counts up to 10,000, repeats nested up to 12 deep, 200,000 commands run and 50,000 lines drawn. Going over a limit stops with a message rather than drawing half the picture.

Why does repeat 360 [fd 1 rt 1] draw a circle?

It draws a regular polygon with 360 sides of 1 step, turning 1° each time, which looks round. Its corners lie on a circle of radius 1 / (2 sin 0.5°) = 57.2965 steps; the tool’s drawing matches that to 0.000000001 in our tests, and the table below does the same for other polygons.

When does a star close?

The turtle is back where it started, facing the same way, when the total turn is a whole number of full turns. repeat 5 [fd 100 rt 144] turns 720° (two full turns) and closes as a five-point star; the table below checks a few more.

What is in the CSV?

Every line the turtle drew, in order: its start and end point in steps, its colour and its width.

Can it print at real size?

Yes, when the drawing fits on one sheet: choose Real size and set the size. Every printed point is within 0.2 mm of its true place in our tests, on US Letter and A4, as long as you print at 100% (Actual size); the check bar in the footer lets you confirm the scale. Bigger drawings print fitted to the page.

Is it free?

Yes. There is no sign-up, no watermark and no limit.

Is anything uploaded?

No. Your program is read and drawn by JavaScript in your browser. Nothing you type is sent anywhere or saved when you close the page.