Heparin is an anticoagulant or "blood thinner". Heparin is always given to patients undergoing open-heart surgery to prevent blood from clotting when a patient is placed on the heart-lung machine. Heparin works by combining with a protein in blood to prevent other proteins from working together to form a clot. The protein that heparin combines with seems to be different in infants and young children compared to adults.