Pectin and agar are both gelatinous substances that have a variety of applications, including applications in food. Both come from vegetable sources; pectin is a soluble fiber found in plants, while agar comes from various species of algae. Chemically, they're closely related, and both consist of long strands of sugar molecules.
Pectin is a large molecule that falls into the biochemical category of a heteropolysaccharide, explain Drs. Reginald Garrett and Charles Grisham in their book "Biochemistry." Polysaccharides are long chains of sugar molecules, or monosaccharides, and the prefix "hetero" means that pectin consists of several different monosaccharides. Pectin is sometimes referred to as a type of soluble fiber, meaning that although it dissolves in water, your digestive tract can't break it down to the same extent that it can sugars and starches.
In the American diet, pectin is commonly added to jams and jellies to thicken them. It also occurs naturally in many foods, including fruits and vegetables. Because you can't break it down effectively, the pectin in your food doesn't do much for you nutritionally; it doesn't contain calories, and neither does it provide your cells with the building blocks they need to make functional and structural molecules. It does, however, help to increase stool bulk and can relieve constipation.
Agar is best known to most Americans as the jellylike substance that biologists use to culture bacteria. In Asia, however, it's a gelling agent used to make a variety of desserts. The structure of agar is somewhat similar, from a macroscopic perspective, to that of pectin; like pectin, it's made up of monosaccharide units. Agar is a bit more consistent in its structure than pectin, however; it consists mainly of the monosaccharide galactose, which is similar to glucose, explain Drs. Mary Campbell and Shawn Farrell in their book "Biochemistry."
Like pectin, agar is a soluble fiber, and serves as a bulking agent for stools, which can help improve bowel regularity. You can't digest it well, so like pectin, it doesn't provide significant nutrition. Its most important application in science is as a growth medium for bacteria; it's possible to mix various nutrients with agar to produce the perfect growing medium for many microorganisms, and scientists can use different agar additives to select for and monitor the growth of bacterial species.