We all have to buy groceries and that can be expensive. So why not get some money back by paying at the supermarket with a cash-back credit card? There are a number of great cash-back credit cards that will help you save money—up to 6 percent on your grocery bill.

To figure out which card is best you need to take into account not just the cash-back percentage a card offers, but also the fees, waivers, and rebate rules that come with the card.

A tool that we recently launched, the Credit Card Adviser Comparison Tool, can help. It calculates the costs and benefits of more than 50 cash-back credit cards to point you toward the best deals, based on what you buy.

Best Cards for Groceries

 If you plug into the Credit Card Adviser Comparison Tool the average amount of money U.S. households spend on groceries every month, you'll find the best cards for the average family. According to the U.S. Bureau of Labor Statistics, for the year ending in June 2015—the latest data available—the typical family spent $375 per month on groceries. According to our calculator, in this scenario, one card comes up tops for cash-back: American Express Blue Cash Preferred.

Over the first three years you have it, Amex Blue Preferred would earn $735 in cash back. The card offers a 6 percent rebate on charges up to $6,000 per year in U.S. supermarkets. (We look at the first three years, because sign-up bonuses and fee waivers can pump up first-year cash-back totals, but they may not continue in subsequent years.)

Another Amex card, Blue Cash Everyday, was second best, returning an impressive $505 over the first three years. This card earns only 3 percent on supermarket purchases up to $6,000 per year.

Four other cards earned about $400 to $420 in our first-three-years' comparison: Chase Freedom and Bank of America's BankAmericard Cash RewardsBankAmericard Cash Rewards for Students, and Pink Ribbon BankAmericard Cash Rewards.

How to Optimize Your Cash-Back

  • Use your cash-back credit cards strategically. For example, if the American Express Blue Cash Preferred also turns out to be the best card for you, use it to buy groceries, but pull a different card from your wallet for gas, such as the PenFed Platinum Cash Rewards Plus Visa or USAA Cashback Rewards Plus American Express. Those last two credit union cards paid back $342 over the first three years of use in our comparison to find the best cash-back cards for gas. And both card issuers also scored highly in our Ratings of banks and credit unions. The Blue Cash Preferred card, by contrast, only offers 3 percent back on gas purchases vs. 5 percent with PenFed and USAA.
  • Shop at traditional supermarkets. Cash-back categories are typically determined by the store's "merchant category code." Traditional supermarkets include stores like Safeway, Trader Joe's, Whole Foods, and Winn-Dixie. While you can also buy groceries at Target and Walmart, you won't get the 6 percent cash back since some issuers, such as Chase Freedom and Amex Blue don't recognize them as grocers. An added benefit, says Vani Hari, the owner of FoodBabe.com. is that shopping at a supermarket also gives you access to more affordable, store-brand organic foods.
  • Pay your credit card balance in full each month. Our comparison calculations assume that the cardholder pays off the entire balance each month. If you don't, the finance charges that come with carrying a balance can wipe out any cash-back benefits.
  • Maximize your cash-back with the Credit Card Adviser Comparison Tool. You may spend more or less on groceries than the average annual household expenditure we used to compare cash-back credit cards. To find the best cards for your unique shopping patterns, plug the amount you spend each month on groceries into the Credit Card Adviser Comparison Tool. You can also further customize your search to include your spending on gasoline, restaurants, travel, and other purchases.

Keep in mind that some cards have been excluded from our comparison tool because they place restrictions on how you can receive the cash back. For example, a cash-back card could give you 2 percent back, but only if you accept it as a statement credit exclusively for travel purchases.