Once roasted, whole coffee beans keep reasonably well for a couple of weeks at room temperature, or a couple of months in the freezer, before becoming noticeably stale. One reason that whole beans keep as long as they do is that they’re filled with carbon dioxide, which helps exclude oxygen from the porous interior. Once the beans have been ground, room-temperature shelf life is only a few days.
From the book On Food and Cooking (2nd edition) by Harold McGee. © 2004 Harold McGee.
By permission of Scribner, a division of Simon & Schuster, Inc.