When you cut into a perfectly ripe, vibrant green avocado but don't finish the fruit in one sitting, the last thing anyone wants is to watch it turn brown after putting it in the fridge.

Thankfully, cookbook author and recipe developer Nicole Keshishian Modic has found a solution.

Modic, who regularly tests viral food hacks, shared her favorite way to preserve avocados with "Good Morning America."

The KaleJunkie creator shared this air-tight trick using a sliced onion to stop the avocado's flesh from turning brown.

"The onion releases sulfur, which keeps your avocado green," she said, explaining the chemical reaction that halts the oxygen from interacting with the enzymes in an avocado.

VIDEO: Here’s how to keep your cut avocados perfectly green
Nicole Keshishian Modic of KaleJunkie shows us her trick to storing avocado halves.

After three days in the fridge, stored in a sealed glass container, Modic said her test avocado was "still perfectly green."

"Unlike the method where people were submerging half-eaten avocados into water as a method of preservation, this method doesn’t come with the risk of listeria," Modic said.

She added, "While you might taste a tiny tinge of onion, it’s definitely not overpowering and it's super subtle."

She suggested using that avocado "on a piece of toast, but maybe not if I'm making a batch of avocado brownies."

Modic added that another popular method to help slow the browning process, "squeezing a lemon over the [leftover] avocado half" was "also a good option." But, she explained, "It's never lasted a full three days without browning in the fridge ... same with the method of storing leftover avocado with a pit."

Editor's note: This was originally published on Feb. 6, 2023.