Cast-On Calculator
Get the stitch count for your target width, and if you're using a long-tail cast-on, exactly how much tail to leave — so you're not unraveling a half-cast-on row because you ran short six stitches from the end.
Why the tail length is the part people get wrong
Casting on the right stitch count is simple proportional math — width times gauge. Guessing the tail for a long-tail cast-on is the part with no clean formula, because it depends on both the stitch count and how thick the yarn is: each stitch uses roughly its own length of tail yarn to form, so a thicker yarn needs more tail per stitch than a fine one, and a wider piece needs more stitches, which compounds the total. This calculator uses a per-stitch length that scales with yarn weight, plus a small safety buffer, so "measure roughly three times the width and hope" becomes an actual number.
When to still leave extra
Add more buffer than this calculator suggests if you tend to cast on tightly (a snug cast-on uses less yarn per stitch, so a looser knitter needs comparatively more), if the yarn is highly textured or a fuzzy novelty fiber (harder to judge and unravel if you come up short), or if you simply don't want to risk re-casting on a large stitch count. Running a few extra inches long costs you a slightly bigger tail to weave in; running short costs you starting over.
When to reach for a different cast-on entirely
Long-tail gives a firm, classic edge that suits most projects, but it isn't always the right choice: a provisional cast-on is worth using when you'll later pick up those live stitches (a toe-up sock, a seamless join, or a bottom-up-to-top-down hybrid), a tubular cast-on suits ribbing that needs to match a bind-off edge invisibly, and a cable or knit-on cast-on is easier to keep loose and stretchy for something like a sock cuff. If your pattern doesn't specify, long-tail is a safe, sturdy default for most edges that won't be picked up again later.