Horsfield was born in Philadelphia and studied medicine at the University of Pennsylvania. In 1800 he travelled to Java for the first time and worked there as a doctor for many years. The East India Company took control of the island from the Dutch in 1811, and Horsfield began to collect plants and animals on behalf of his friend Sir Thomas Stamford Raffles. In 1819 he was forced to leave the island due to ill health and became keeper and later curator of the East India Company's museum in Leadenhall Street, London.
Horsfield wrote Zoological Researches in Java and the Neighbouring Islands (1824). He also classified a number of birds with Nicholas Aylward Vigors, most notably in their A description of the Australian birds in the collection of the Linnean Society; with an attempt at arranging them according to their natural affinities (Trans. Linn. Soc. Lond. (1827)). Together with the botanists Robert Brown and John Joseph Bennett he published the Plantae Javanicae rariores (1838–52).
Horsfield was appointed assistant secretary of the Zoological Society of London at its formation in 1826. In 1833, he was a founder of what became the Royal Entomological Society of London. He was elected a fellow of the Royal Society in 1828.
Horsfield is commemorated in the names of a number of animals, including the Russian Tortoise Testudo horsfieldii, the Javanese Flying Squirrel Iomys horsfieldii, the Horsfield's Fruit Bat Cynopterus horsfieldi and the Malabar Whistling-thrush Myophonus horsfieldii.