If you bought a bag of sugar in the past year or two, you've probably noticed that it costs more than it used to. Sugar prices have recently flirted with a 30-year high. And since many companies buy lots of bags of sugar, the price hikes have hit them even harder.

Rising sugar costs can pressure the profit margins of heavy consumers such as Hershey (NYSE: HSY) and Tootsie Roll (NYSE: TR). Increasing the prices of their finished products can boost margins, but may also drive down consumer demand. With the right pricing strategy, both the company and its shareholders can benefit. Hershey has been effectively cutting costs to try to offset rising commodity expenses, but it can't do so forever.

Some companies will feel less of a pinch than usual by reducing their sugar consumption. Alternative sweeteners and low-sugar or no-sugar drinks have grown in prominence at Coca-Cola (NYSE: KO) and PepsiCo (NYSE: PEP), and cereal producers such as General Mills (NYSE: GIS) and Kellogg have bowed to health-conscious shoppers by cutting back on sugar.

Sweet or sour future
Sugar prices have risen both from a surge in demand, as sugar-based ethanol is increasingly used for fuel, and from supply cutbacks by Brazil and other producers. Alas, supply may not rise much anytime soon. U.S. Department of Agriculture recently rejected Monsanto's (NYSE: MON) herbicide-resistant sugar-beet seeds, which could ultimately lead to as much as a 20% reduction in U.S. sugar production

That might seem like good news for companies such as Imperial Sugar (Nasdaq: IPSU), one of the largest producers of sugar from sugar cane. But if prices get so high that consumers start looking for long-term substitutes, the whole industry will lose. Investors in sugar-related companies need to keep an eye on these not-so-sweet developments.

Kellogg, Coca-Cola, and PepsiCo are Motley Fool Income Investor recommendations. Motley Fool Options has recommended a synthetic long position on Monsanto and a diagonal call position on PepsiCo. The Fool owns shares of Coca-Cola, which is a Motley Fool Inside Value recommendation. Try any of our investing newsletter services free for 30 days.

Longtime Fool contributor Selena Maranjian owns shares of Coca-Cola and PepsiCo. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.