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.
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
- Pick an example program, or type your own in the box.
- Use fd / bk to move, lt / rt to turn, pu / pd to lift and lower the pen, and repeat N [ … ] to loop.
- Set the pen colour and line width, or change them inside the program with color and width.
- Choose Fitted to one page, or Real size and how long one step is.
- 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
| Example | Program (first line) | Lines drawn | Commands run | Back at the start |
|---|---|---|---|---|
| Square: repeat 4 [fd 100 rt 90] | repeat 4 [fd 100 rt 90] | 4 | 9 | yes |
| Triangle | repeat 3 [fd 120 rt 120] | 3 | 7 | yes |
| Hexagon | repeat 6 [fd 60 rt 60] | 6 | 13 | yes |
| Circle: repeat 360 [fd 1 rt 1] | repeat 360 [fd 1 rt 1] | 360 | 721 | yes |
| Five-point star | repeat 5 [fd 150 rt 144] | 5 | 11 | yes |
| Nine-point star | repeat 9 [fd 150 rt 160] | 9 | 19 | yes |
| Square spiral (repcount) | repeat 120 [fd repcount * 2 rt 90] | 120 | 241 | 169.7 steps away |
| Twisted spiral: turn 91° | repeat 200 [fd repcount rt 91] | 200 | 401 | 141 steps away |
| Ring of 36 squares | repeat 36 [repeat 4 [fd 80 rt 90] rt 10] | 144 | 361 | yes |
| Flower of 12 petals (arcs) | repeat 12 [ … | 1,440 | 2,953 | yes |
| Sun: 36 rays | repeat 36 [fd 80 bk 80 rt 10] … | 108 | 186 | 20 steps away |
| Dashed circle (pen up and down) | repeat 36 [pd fd 5 pu fd 5 rt 10] | 36 | 181 | yes |
| Five pentagons | repeat 5 [repeat 5 [fd 80 rt 72] rt 72] | 25 | 61 | yes |
| Two stars in two colours and widths | color red width 0.4 … | 10 | 27 | yes |
| Real size: 100 mm square (1 step = 1 mm) | repeat 4 [fd 100 rt 90] | 4 | 9 | yes |
Counts are worked out by the tool when it runs each program.
The commands
| Command | Short form | What it does |
|---|---|---|
| forward N | fd N | Move N steps the way the turtle faces, drawing if the pen is down |
| back N | bk N | Move N steps backwards |
| left A / right A | lt A / rt A | Turn A degrees counter-clockwise / clockwise |
| setheading A | seth A | Face compass heading A (0 = up, 90 = right) |
| penup / pendown | pu / pd | Lift or lower the pen |
| repeat N [ … ] | Run the commands in brackets N times; repcount counts 1, 2, 3 … | |
| color NAME | colour NAME | Change the pen colour (a name or #rrggbb) |
| width W | Change 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 N | Turn each time | Total length (steps) | Back at the start | Radius of the corners (steps) |
|---|---|---|---|---|
| 3 | 120° | 30 | yes | 5.7735 |
| 4 | 90° | 40 | yes | 7.0711 |
| 5 | 72° | 50 | yes | 8.5065 |
| 6 | 60° | 60 | yes | 10 |
| 8 | 45° | 80 | yes | 13.0656 |
| 12 | 30° | 120 | yes | 19.3185 |
| 36 | 10° | 360 | yes | 57.3686 |
| 90 | 4° | 900 | yes | 143.2685 |
| 360 | 1° | 3600 | yes | 572.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 N | Turn A | Total turn | Closes |
|---|---|---|---|
| 5 | 144° | 720° | yes |
| 7 | 154.2857° | 1080° | yes |
| 8 | 135° | 1080° | yes |
| 9 | 160° | 1440° | yes |
| 12 | 150° | 1800° | yes |
| 5 | 72° | 360° | yes |
| 6 | 144° | 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
| Download | What is in it |
|---|---|
| The 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 DPI | The same sheet as a picture |
| SVG | The drawing at the printed size, one path per colour and width |
| CSV | Every 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 want | Use |
|---|---|
| Type turtle commands and print the drawing | Turtle Graphics (this page) |
| Fractal trees and curves from L-system rules | Fractal Generator |
| Rolling-circle curve art | Spirograph Generator, Epicycloid, Hypocycloid |
| Any drawing traced by turning circles | Fourier 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.
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.