Barnhart was born in Brooklyn, New York to John Wesley Barnhart and Emma Miller Barnhart. He attended Wesleyan University in Middletown, Connecticut, receiving an A.B. in 1892 and an A.M. the following year. In 1896 he graduated from Columbia University College of Physicians and Surgeons receiving an M.D., though he never practiced medicine. His decision not to practice medicine was apparently made possible by substantial private income.
In 1903 he became an editorial assistant at the library of the New York Botanical Garden (NYBG). 1905 saw the first appearance of North American Flora, written by Nathaniel Lord Britton and Lucien Marcus Underwood. Barnhart was responsible for reviews of manuscripts including proof-reading and bibliographic correction. Barnhart developed a style of taxonomic citation, which is still used in the Index to American Botanical Literature.
In 1907 he became NYBG librarian when Anna Murray Vail, its first librarian, retired. From 1908 to 1926, and again in 1932 he was appointed NYBG library vice president. During the 5 years of his tenure as librarian, the number of bound volumes increased by 20%. He also gave his personal library of 1900 items including many rare volumes.
In January 1913, Barnhart was made Bibliographer of the Garden, a title he would keep for 30 years. His principal responsibility in this capacity was North American Flora. It was during this period that he created the "Barnhart bibliographic file" consisting of about 50,000 cards with bibliographic information and formed the basis of his biographical books.