String Art Generator, Explained
After reading this you will understand how a single thread wound around a ring of nails reproduces a photograph, how to estimate the thread length before you buy, and how to set nail count, contrast and skip so the finished piece looks like your source image.
String art portraits look like magic: one continuous black thread, wound back and forth thousands of times, resolves into a face. There is no magic. Each straight line between two nails darkens the strip of board it crosses by a tiny amount. Stack a few thousand lines and the places where many lines overlap turn dark, while the places few lines touch stay light. The generator does the bookkeeping: it decides, one line at a time, which nail to go to next so that the accumulated darkness matches your photo.
What the tool does and one example
Picture 300 nails evenly spaced around a circle 50 cm across. The thread starts at nail 0. From there it can run to any of the other 299 nails, drawing a straight chord. The generator looks at every possible chord, measures how much still-missing darkness each one would cover, and picks the best. The thread then continues from that nail to the next, and so on for a few thousand lines.
The result is a portrait built entirely from straight lines. A photo with a bright face against a dark background, say a single strong light source, comes out crisp. A flat, evenly lit snapshot comes out muddy, because there is little difference in darkness for the lines to build.
The line is the atom of string art. A 50 cm circle with 300 nails offers about 44,850 possible chords. The generator never draws all of them; it draws the few thousand that best explain your image, reusing each nail many times.
When to use it, and when not to
Use string art when your image has strong contrast and a clear subject: a portrait with directional lighting, a pet against a plain wall, a bold logo. Crop tight so the face fills the circle. The technique loves edges and shadows.
Avoid it for images that depend on color, fine text, or subtle mid-tone gradients. String art with one thread color is grayscale, and it is coarse: a 300 nail circle resolves detail no finer than the nail spacing, roughly 5.2 mm on a 50 cm frame. If you want color and per-pixel control, a Cross-Stitch Pattern Maker chart will serve you better.
The greedy algorithm and its math
The generator holds two images in memory. One is the target: your photo, inverted so that dark pixels hold a large number and light pixels hold a small one. The other is the canvas, which starts empty and accumulates the lines drawn so far. At each step it wants to draw the line that removes the most remaining error.
For a candidate chord from the current nail to nail j, it walks the pixels the thread would cross and averages the darkness still missing there:
Here L_j is the set of pixels under the chord to nail j, T_p is the target darkness at pixel p (0 for white, up to 1 for black) and D_p is the darkness the threads so far have laid down there. Pixels that are already too dark count against the chord, but only lightly, through g. The nail with the largest S_j wins, and the winding stops early if no chord scores above zero.
After drawing that line, every pixel along L_j gets darker by the fraction w_p of it that the real thread covers, stacking the way real threads do:
With the default 0.25 mm thread on a 50 cm frame, w_p \approx 0.24. Each pass leaves less darkness missing along its path, so the next line finds less to gain there and the algorithm spreads its lines out instead of piling them all in one place. This is why the method is called greedy: it never plans ahead, it just takes the best single line available right now, then updates and repeats.
Skipping the nearest few nails on each step stops the thread from drawing tiny chords that hug the rim. Those short lines cover almost no pixels but still cost thread and darken the edge. If your circle comes out with a heavy dark ring, raise the skip.
Estimating thread length before you buy
You want to know how much thread to order. The lines are chords of a circle, and their lengths vary with how far apart the nails are. The average length of a random chord, taken over all nail pairs, works out close to 0.6366 of the diameter, which is 2/\pi.
N is the number of lines, D is the frame diameter. For a 50 cm circle with 3,000 lines: 3000 \times 0.6366 \times 0.5 \approx 955 m, so buy a full kilometer to be safe. The generator reports the exact sum of the chords it actually chose, which runs a little above this average because it favors long lines that cross more of the picture.
A worked example with the demo data
240 nails, 50 cm circle, 3,000 lines
Load the demo and the defaults give a 50 cm circular frame, 240 nails, 3,000 lines, and a thread 0.25 mm wide. Follow the numbers:
- Nail spacing: the circumference is \pi \times 500 \approx 1571 mm, divided by 240 nails gives
6.5mm between nails. - Pixel scale: the generator works on a 480-pixel grid, so on a 500 mm circle each pixel is about
1.04mm wide. - Coverage per line: a
0.25mm thread over a1.04mm pixel darkens each crossed pixel by about w_p = 0.24 of one pass. - Average line length: 0.6366 \times 500 = 318 mm per line.
- Total thread: 3000 \times 318 = 954{,}900 mm, about 955 m.
- Winding time: reading and placing one nail takes 5 to 8 seconds by hand, so 3,000 lines is roughly 4 to 6.5 hours of winding.
Every one of these is checkable against the tool's readout. If you halve the frame to 25 cm, the thread drops to about 477 m, but each 0.25 mm thread now covers twice as much of the picture, so the same 3,000 lines come out darker: use fewer lines or a finer thread on small frames.
Reading and interpreting the results
The grey preview is your proof. It draws every thread at its true width for the frame size, so what you see is close to the finished board. Look at it before you commit: if the face is legible in the preview it will be legible in thread. If it is a grey smear, no amount of careful winding will rescue it.
Watch how darkness accumulates as line count rises. The first few hundred lines lay down the broad shadows. The next thousand build mid-tones. Beyond that, each new line changes very little, because most of the remaining target darkness is already covered. That is diminishing returns in action.
Common mistakes
The three failures below account for most disappointing results.
- Too little contrast
- A flat photo gives the algorithm nothing to grab. Push the contrast until the grey preview looks like a pencil sketch with clear blacks and whites.
- Frame too large for the line count
- 3,000 lines on a 50 cm circle is dense enough. The same 3,000 lines on a 1 m circle spread twice as thin and look faint. Either add lines or shrink the frame.
- Wrong thread width in the settings
- If you tell the tool the thread is
0.2mm but wind with0.5mm thread, the real board comes out far darker than the preview, because each pass covers 2.5 times more pixel area than modelled.
Do not trust the preview if your printed nail template is scaled wrong. Print at 100% (no "fit to page"), then measure the template diameter with a ruler before you place a single nail. A template printed at 96% turns a 50 cm plan into 48 cm, and every thread length in the readout is then off by the same 4%.
Related tools
String art is one way to turn a photo into a physical craft, but not the only one. For a color chart with symbols and a thread legend, use the Cross-Stitch Pattern Maker. When you need to print the nail template or any layout at exact size, the Graph Paper Generator is a fast way to check your printer's scale against a known grid. If your project moves on to a box or stand, the Papercraft Box Generator builds true-scale nets, and for tension math on a knitted or crocheted piece see the Knitting & Crochet Gauge Converter.
Frequently asked questions
How many nails should I use?
200 to 300 is the useful range for a 40 to 60 cm frame. Fewer than 150 leaves visible gaps at the rim; more than 400 gives spacing under 4 mm, hard to nail cleanly and offering detail the thread cannot actually resolve.
How much thread do I need?
Multiply the number of lines by 0.6366 and by the diameter. For 3,000 lines on a 50 cm circle that is about 955 m, so buy 1 km. The tool reports the exact figure for the winding it chose.
Why does my finished piece look darker than the preview?
Almost always the real thread is thicker than the width you entered, or you wound more passes over the same nails than the plan. Measure your thread and match the setting. Doubling the width roughly doubles the darkness each pass adds.
Can I use white thread on a dark board?
Yes. Invert the image first so light areas become the ones the thread builds up. The math is identical; only the meaning of dark and light swaps.
Does line count past 3,000 ever help?
Rarely on frames under 60 cm. The error curve flattens: on the test portrait, lines past 3,000 lower the remaining error by less than half a percentage point, while every 1,000 extra lines add about 318 m of thread on a 50 cm circle. Spend that thread only if the preview still shows missing shadow.