How long do hard-boiled eggs stay fresh?

Hard-boiled eggs may be the perfect protein-packed snack. They're also incredibly versatile chopped up into salads or as the base for a delicious platter of deviled eggs.

But, as anyone who's accidentally left a boiled egg sitting out for too long knows, when an egg goes rotten, it's not a pretty sight ... or smell, really.

The absolute best way to tell if your hard-boiled egg has turned is to trust your gut and your nose. If it reeks of sulfur, just toss it. But if you don't trust your sense of smell, here's what you should know about how long hard-boiled eggs usually last.

According to the U.S. Food and Drug Administration, hard-boiled eggs in or out of their shells should be consumed within a week after cooking. They don't last as long as raw eggs because during the cooking process, the shell's protective coating is compromised, and the open pores make it easier for bacteria to get inside and contaminate the egg.

One exception to the week-long rule is soft-boiled eggs.

"Soft boiled eggs spoil faster," Emily Rubin RD, LDN at Thomas Jefferson University Division of Gastroenterology and Hepatology told TODAY. If you don't eat soft-boiled eggs right after cooking them, it's OK to keep them in their shell and refrigerate them for up to two days. While the whole point of a soft-boiled egg is to have a creamy yolk, Rubin isn't a fan of the technique. "To prevent salmonella, cook eggs thoroughly so that both the yolk and white are firm."