It is possible to determine the gender of rats as soon as they are born. It just takes a bit of practice.
A doe has two visable openings placed close together. A buck has two visable openings placed further apart, and the opening closest to the tummy extends slightly, like a tiny tube.
Another way to sex young rats is by looking for a nipple line. Bucks do not have nipples, whereas does do. Nipples don’t appear on the does until they are approximately 10-14 days old and are quite hard to see once they are fully furred unless they are nursing a litter.
Juveniles are much easier to sex. By the age of four weeks the bucks will have descended testicles and these are relatively easy to spot.
However, bucks have the ability to pull their testicles into their body cavity, making it possible to mistake a male for a female at this age.
If the rat does not have testicles showing, look at the distance between the two openings. In bucks they will be noticeably further apart than in does, even moreso than when they are pinkies.
Adults are very easy to sex. By this stage the testicles are fully descended and are exceptionally hard to miss!
If a rat is hot, they will hang further out than normal to keep them cool, just like humans. Although they will draw their testicles close to their body when cold, they are still obvious.
Adult does look much the same as the juvenile stage, they will have two openings that are placed close together, and will have nipples under their fur.