Torus Knot Generator
Draw a torus knot: a closed loop that winds p times round the centre of a ring-shaped torus and q times round its tube. Type p and q from 1 to 12. When p and q share no factor the loop is a knot (2 and 3 give the trefoil); when they share a factor d you get a torus link of d separate loops, and the tool says so. The flat diagram shows the knot seen down the middle of the ring: the tool finds every crossing, puts the strand that is nearer you on top and breaks the other one, so the drawing is a true knot diagram. Or show it as a shaded 3D tube, turn and tilt it, and press Spin. It prints on US Letter or A4, filling the page or at a width and height you type. Download a PDF, a 300 DPI PNG, an SVG or a PNG of the 3D view. Nothing is uploaded.
100% private — everything runs in your browser. Everything runs in your browser; nothing is uploaded.
Print at 100% (Actual size). The SVG holds the same strands or shaded faces as the PDF.
Knot
3D view
Look
Size
Page
Runs in your browser with our own code: nothing you type is uploaded or saved. Every point, crossing and face comes from the torus knot formula by our own code. You may use what you make here, including commercially, with no credit needed.
How to draw and print a torus knot
- Pick a preset, or type p and q.
- Choose the flat diagram or the 3D tube.
- For the diagram, choose fewest crossings or as typed, the line width and the gap.
- Set the path ratio, the tube thickness, the turn and the tilt; press Spin to turn it.
- Choose the colours and fill the page or a width and height.
- Download the PDF and print at 100% (Actual size), or the PNG, SVG or 3D view PNG.
What you can use it for
- Knot theory and topology lessons: crossings, links, the trefoil
- Posters and prints of knots
- Logo and pattern sketches from a knot outline
- Laser, vinyl and plotter art from the SVG strands
- Checking a knot drawing by hand against the crossing count
- 3D renders for slides and worksheets
The 15 presets
| Preset | (p, q) | Knot or link | Crossing number | Crossings found in the flat diagram | Drawn as |
|---|---|---|---|---|---|
| (2, 3): the trefoil, 3 crossings | (2, 3) | knot | 3 | 3 | 3 strands |
| (2, 5): 5 crossings | (2, 5) | knot | 5 | 5 | 5 strands |
| (2, 7): 7 crossings | (2, 7) | knot | 7 | 7 | 7 strands |
| (3, 4): 8 crossings | (3, 4) | knot | 8 | 8 | 8 strands |
| (3, 5): 10 crossings | (3, 5) | knot | 10 | 10 | 10 strands |
| (4, 5): 15 crossings | (4, 5) | knot | 15 | 15 | 15 strands |
| (3, 7): 14 crossings | (3, 7) | knot | 14 | 14 | 14 strands |
| (5, 2) drawn as typed: 8 crossings, not the fewest | (5, 2) | knot | 5 | 8 | 8 strands |
| (2, 4): a torus link of 2 loops | (2, 4) | link of 2 | – | 4 | 4 strands |
| (3, 6): a torus link of 3 loops | (3, 6) | link of 3 | – | 12 | 12 strands |
| 3D tube: the trefoil | (2, 3) | knot | 3 | 3 | 1,120 faces |
| 3D tube: (3, 8) | (3, 8) | knot | 16 | 16 | 2,688 faces |
| 3D tube: (5, 7) | (5, 7) | knot | 28 | 28 | 2,352 faces |
| 3D tube: (2, 9) on a dark page | (2, 9) | knot | 9 | 9 | 3,024 faces |
| Real size: trefoil in a 100 mm square | (2, 3) | knot | 3 | 3 | 3 strands |
Worked out by the tool on US Letter.
Crossings: formula against what the tool finds
| (p, q) | gcd | Knot or link | Crossing number min((p − 1) q, (q − 1) p) | Found, fewest crossings | Found, as typed (p round the centre) | Genus (p − 1)(q − 1) / 2 |
|---|---|---|---|---|---|---|
| (2, 3) | 1 | knot | 3 | 3 | 3 | 1 |
| (2, 5) | 1 | knot | 5 | 5 | 5 | 2 |
| (2, 7) | 1 | knot | 7 | 7 | 7 | 3 |
| (3, 4) | 1 | knot | 8 | 8 | 8 | 3 |
| (3, 5) | 1 | knot | 10 | 10 | 10 | 4 |
| (4, 5) | 1 | knot | 15 | 15 | 15 | 6 |
| (3, 7) | 1 | knot | 14 | 14 | 14 | 6 |
| (5, 6) | 1 | knot | 24 | 24 | 24 | 10 |
| (5, 7) | 1 | knot | 28 | 28 | 28 | 12 |
| (7, 5) | 1 | knot | 28 | 28 | 30 | 12 |
| (2, 4) | 2 | link of 2 | – | 4 | 4 | – |
| (3, 6) | 3 | link of 3 | – | 12 | 12 | – |
| (4, 6) | 2 | link of 2 | – | 18 | 18 | – |
| (1, 5) | 1 | unknot | 0 | 0 | 0 | 0 |
Formulas from Wikipedia’s Torus knot page (read 13 November 2026); the crossing number and genus are for knots only. The found columns are counted by the tool, segment against segment.
What prints
| Download | What is in it |
|---|---|
| The diagram as broken strands at the line width you set, or the 3D tube as shaded faces, with the crossings, line and gap in the footer and a check bar | |
| PNG 300 DPI | The same sheet as a picture |
| SVG | The same strands or faces |
| 3D view PNG | The 3D view at the turn and tilt you set, 1600 × 1600 pixels |
To cut the strands, use SVG to DXF; for knotwork borders and panels, the Celtic Knot Generator.
Which tool to use
| You want | Use |
|---|---|
| Any (p, q) torus knot or link, flat or 3D | Torus Knot Generator (this page) |
| Knotwork panels, borders and a triquetra | Celtic Knot Generator |
| Curves from two sine waves | Lissajous Curve |
| Rolling-circle curves | Spirograph Generator |
Other tools: the Spirograph Generator draws rolling-circle curves, and the Fractal Generator fractals.
More free tools
Maths shapes and printables?
Drawing and print tools that run privately in your browser, with no sign-up and no watermark.
Frequently asked questions
What is a torus knot?
A knot that lies on the surface of a torus (a ring shape). The (p, q) torus knot winds q times round a circle inside the torus and p times round its axis. It is a knot when p and q have no common factor; when they do, the curve splits into a torus link of gcd(p, q) loops.
What are p and q?
p is how many times the curve goes round the centre of the ring, and q is how many times it goes round the tube. The (2, 3) torus knot is the trefoil. The (p, q) and (q, p) torus knots are the same knot, drawn differently.
How many crossings does a torus knot have?
Its crossing number, the fewest crossings any drawing of it can have, is min((p − 1) q, (q − 1) p) for p and q above 0. The trefoil has 3 and the (3, 4) torus knot has 8. The tool shows it under the options and the table below compares it with the crossings it finds.
Does the diagram really have that many crossings?
Yes. The tool does not draw crossings from a formula: it finds every place where the curve crosses itself, segment against segment. Seen down the middle with the smaller of p and q going round the centre, it finds exactly the crossing number for every knot in our tests; drawn as typed with the larger number round the centre it finds q(p − 1), which is more.
How does it decide which strand goes over?
From the real depth. At each crossing it works out how far each strand is from you, puts the nearer one on top and breaks the other by the gap you set on each side of the top strand.
What is a torus link?
When p and q share a factor d, a single loop cannot visit all of the curve: the drawing becomes d separate loops, each a (p/d, q/d) torus knot, linked together. The (2, 4) torus link has 2 loops and the (3, 6) has 3. The tool draws each loop and gives the count.
When is a torus knot not knotted?
When p or q is 1: the loop can then be untangled into a plain circle, the unknot. The tool says so, and the diagram has no crossings when 1 goes round the centre.
How is the 3D tube drawn?
The curve is swept by a small circle that is kept from twisting as it moves along, then every face is shaded by one light and drawn from the back to the front. Turn and tilt set where you look from; Spin turns it one degree a frame and stops after two turns, or as soon as you change something or leave the tab.
Is this the same as the Celtic knot generator?
No. That tool draws knotwork panels, borders and a triquetra, which is the trefoil. This page draws every (p, q) torus knot and torus link, with the crossings found and the depth.
Is it free?
Yes. There is no sign-up, no watermark and no limit.
Is anything uploaded?
No. Every point, crossing, face and strip is worked out by JavaScript in your browser. Nothing you type is sent anywhere or saved when you close the page.