It’s about to get easier to compare prices at some big online stores.

Eric Schneiderman, New York’s attorney general, said Tuesday that Costco, CVS, FreshDirect, Wal-Mart and Walgreen have agreed to list unit prices on their websites and mobile apps for shoppers nationwide in the coming months. Amazon.com Inc., the world’s largest online retailer, did not agree to participate, according to Schneiderman.

“As the internet becomes the shopping mall of the 21st century, we need to ensure that consumers have the same robust protections online that they do in brick-and-mortar stores,” Schneiderman said in a statement. “Making New York more affordable for the middle class includes empowering consumers to spend their money wisely. This agreement, in which government and the private sector worked collaboratively to adapt conventional rules to an evolving marketplace, is a victory for consumers. I commend these retailers for recognizing the need for transparency and promoting openness online.”

A unit price tells consumers how much a product costs by each unit of weight. It divides the full price of the item by the size of its packaging. For example, a 16 ounce bottle of shampoo costing $5.99 would have a unit price of 37 cents per ounce. Because the same product can be sold in several different sizes, a unit price is a better way to compare whether a giant bottle of shampoo is really a good deal compared to a smaller one.

Retailers already list unit prices in stores, but they’re harder to find online.

Costco Wholesale Corp. and Wal-Mart Inc. will add them online before the end of this year. Wal-Mart said it already offers unit prices on some of the pet food it sells at Walmart.com and for the online grocery delivery service it’s testing in San Francisco and Denver.

CVS Caremark Corp., FreshDirect and Walgreen Co., including its Drugstore.com subsidiary, will provide unit prices by March 2015.

All the companies also agreed to add unit pricing for any future online stores they may open.

Amazon lists unit prices for some items, but it doesn’t do so consistently, the attorney general’s office said in a statement. The company promised to list unit prices for its subsidiary Quidsi, which runs Diapers.com, Soap.com and other shopping sites, but didn’t commit to it in writing, the attorney general’s office said. Amazon and Quidsi did not immediately respond to a request for comment.

“Although Amazon displays unit pricing on some of its pages, it does not provide the information uniformly across its platforms. Furthermore, its subsidiaries do not currently display unit pricing,” the statement said.

“Unfortunately for consumers, Amazon refused to agree to provide this information. The company claims it will extend unit pricing to its subsidiary Quidsi, which operates online stores like Soap.com, but refused to commit to that in a written agreement. It also would not agree to extend unit pricing to pages where that information is absent, nor would it commit to continue providing unit pricing information to consumers in the future.”