One measurement, and it is not the dog's weight
Collar size is neck circumference. Not weight, not breed, not the size of the dog in general. Two dogs at the same weight can be two collar sizes apart, because one carries it in the chest and the other in the neck, and the collar only cares about the neck.
Wrap a soft tape where the collar actually sits, which is a little below the jaw and above the shoulders rather than up under the ears. Keep it against the fur without compressing it, and slide two fingers underneath. That number is your size.
The two finger rule is the only safety part
You should be able to slide two fingers flat between the collar and the neck, and no more. Tighter restricts the throat. Looser and the dog can back out of it, which tends to happen when something startles them near a road rather than in the garden.
Everything else on this page is about buying the right thing. This part is about the collar staying on, so check it monthly on a grown dog and fortnightly on anything still growing.
Why the breed option exists, and why it is second
A quarter of everyone searching for dog sizing searches by breed rather than by measurement. That is a real way people think about it, so this page accepts a breed. But it puts the tape first on purpose, because within any breed the spread is genuinely wide: two German Shepherds of the same age and the same breeding can differ by a couple of inches at the neck, and a couple of inches is a whole size.
Use the breed mode to know what to expect before the dog arrives, or to sanity check a number. Use the tape before you buy anything you cannot return.
A puppy cannot be sized by breed at all
This is worth its own section because it is the most common version of the question and the one where the breed answer is not merely rough but wrong. The breed describes an adult. Your puppy will not be that dog for the better part of a year, and the adult neck measurement has nothing useful to say about the animal in front of you today.
Measure the neck you actually have, buy something adjustable and inexpensive, and expect to replace it. A puppy collar is a consumable. The gap closes faster than anyone expects, which is why the fortnightly check matters more than getting the first purchase exactly right.
Letters do not travel between brands
One maker's medium is another's large, and no standards body governs the letters. What does travel is the inch or centimeter range, which every collar worth buying publishes on the listing. Read that and ignore the letter, exactly as you would on a human letter size chart, where the same problem has the same answer.
Collar or harness?
They are sized differently and they solve different problems, which is why they are separate pages here. A collar is sized on the neck and carries identification. A harness is sized on the chest and spreads pulling force across the body, which matters for dogs that pull and for flat-faced breeds where neck pressure is a real risk rather than a theoretical one. Plenty of dogs wear a collar for tags and a harness for walks, and those are two different measurements.
The principle running through this site is the same for dogs as for people: size by the measurement rather than the label. It is why diaper sizing goes by weight rather than age, and why hat sizing goes by head circumference rather than by whether you have a big head.