U.S. chemists are working on a dipstick test that may soon take the guesswork out of deciding if it's safe to reheat those leftovers in the back of the fridge.

Scientists at the University of South Carolina say their kit for determining whether food is spoiled could be on store shelves in two to three years.

They say their diagnostic test, which researchers describe as a dipstick, can detect the presence of chemicals formed by disease-causing bacteria in less than five minutes.

"There's no other test like this targeting the consumer market right now that I am aware of," study leader John Lavigne, assistant professor chemistry and biochemistry, said in a news release.

"It has the potential to change the way individual diners think about the quality of their food and greatly impact public health."

Lavigne sees the kit as a tool that consumers can use at home and carry with them when they eat at restaurants, helping to avoid illnesses and even deaths caused by food poisoning.

Lavigne and colleagues unveiled their invention at the annual meeting of the American Chemical Society on Sunday.

They say preliminary tests with fish show the dipstick has a 90 per cent accuracy rate, changing colour in the presence of a class of chemicals called nonvolatile biogenic amines. These compounds are a byproduct of the decay of food proteins and are an indirect measure of food spoilage.

The polymers in the dipstick change colour as the level of these compounds increases, indicating degrees of food spoilage. A change from dark purple to yellow, for example,means the food is badly spoiled. If the polymers go from dark purple to a reddish hue, that indicates mildly spoiled food.

Depending on the degree of freshness, consumers could then decide whether to eat the food or avoid it.

But Lavigne points out thatyellow would be a clear sign to toss out those leftovers.