Kent Hatch, PhD, and colleagues describe the test in Rapid Communications in Mass Spectrometry's online edition.
They say they developed the test because eating disorders are often shrouded in secrecy.
"Common to both anorexia and bulimia is the element of denial," the researchers write.
"Those who suffer from these illnesses are often unwilling or unable to recognize and admit to the psychopathology of their behaviors," they add.
That can make diagnosis hard because people with eating disorders may not share accurate information about their eating habits.
An objective test could help diagnose eating disorders, note Hatch and colleagues. So they set out to create such a test.
"Researchers, clinicians, and patients would greatly benefit from an objective, biological measure that could aid in diagnosing eating disorders," the researchers write.
Hatch and colleagues analyzed hair from 20 women diagnosed with anorexia and/or bulimia.
Those women were inpatients at an eating disorders treatment facility in Utah.
For comparison, Hatch and colleagues also tested hair from 23 women without eating disorders at Brigham Young University.
Each woman pulled five strands of hair from her head for the test.
The researchers analyzed the hairs' carbon and nitrogen levels, which they say reflect the women's current diets.
The test was 80% accurate in identifying women with anorexia and women with both anorexia and bulimia.
But the test results showed no difference between women with bulimia and those without eating disorders.
That may be because women with anorexia are more malnourished than those with bulimia, the researchers note.
The test may need some refining depending on where and when it's used.
For instance, women in the U.S. eat more corn than those in Europe or Japan. Dietary changes due to travel or seasonal food availability may also matter, Hatch's team points out.