He was born at Hanwell, the son of a schoolmaster. He was educated at Merchant Taylors' School, Northwood, and in 1832 obtained a post in the Public Record Office. In 1838 he became an assistant in the manuscript department of the British Museum, where he attracted the notice of his chief, Sir Frederick Madden, the most eminent paleographer of his day, and in 1852 he was made Egerton librarian. In 1856 he became assistant keeper of manuscripts, and in 1867 was promoted to the post of keeper.
His work in reorganizing the manuscript department was of lasting value, and to him is due the classified catalogue of MSS., and the improved efficiency and punctuality of publication of the department. In 1878 he was appointed principal librarian. Under his supervision were erected the new buildings of the White Wing, which provide accommodation for prints, drawings, manuscripts and newspapers, and the purchase of the Stowe manuscripts was concluded while he remained in office. He founded, in conjunction with Sir E. Maunde Thompson, the Palaeographical Society, and first made classical palaeography an exact science.
He married Caroline Frances Barham, (22 July 1823-1 August 1912), second daughter of the Reverend Richard Harris Dalton Barham.