The five-minute test identifies biological markers in urine created by the breakdown of foods such as red meat, chicken, fish, fruit and vegetables.
It then offers an indication of how much fat, sugar, fibre and protein a person has eaten.
The test comes in response to evidence that people inaccurately record their own diets by under-reporting the unhealthy food they eat and over-reporting fruit and veg intake.
According to scientists, the likelihood of inaccuracies in food diaries increases even further if a person is overweight or obese.
“A major weakness in all nutrition and diet studies is that we have no true measure of what people eat,” said Professor Gary Frost, senior author of the study from the Department of Medicine at Imperial College London.
“We rely solely on people keeping logs of their daily diets ― but studies suggest around 60% of people misreport what they eat to some extent.
“This test could be the first independent indicator of the quality of a person’s diet ― and what they are really eating.”
For the study, conducted by researchers from Imperial College London, Newcastle University and Aberystwyth University, 19 volunteers were asked to follow four different diets, ranging from very healthy to very unhealthy.
The volunteers strictly followed these diets for three days while in a London research facility, during which the scientists collected urine samples in the morning, afternoon and evening.
The research team then assessed the urine for hundreds of compounds, called metabolites, which are produced when certain foods are broken down in the body.
These included compounds that indicate red meat, chicken, fish, fruit and vegetables, as well as giving a picture of the amount of protein, fat, fibre and sugar eaten.
There are also compounds that point to specific foods such as citrus fruits, grapes and green leafy vegetables.
Using this information, experts were able to develop a ‘urine metabolite profile’ that indicated a healthy, balanced diet with a good intake of fruit and vegetables.
The idea is this ‘healthy diet’ profile could be compared to the diet profile from an individual’s urine, to provide an instant indicator of whether they are eating well or not.
Professor John Mathers, co-author from the Human Nutrition Research Centre at Newcastle University, said: “For the first time, this research offers an objective way of assessing the overall healthiness of people’s diets without all the hassles, biases and errors of recording what they’ve eaten.”
The team now hope to refine the technology by testing it on larger numbers of people.
They hope that the urine test, which should be available in two years, will be able to track patients’ diets and could even be used in weight loss programmes to monitor food intake.
The study was published in the journal Lancet Diabetes and Endocrinology.