Irwin was born in Pittsburg or Lancaster, Pennsylvania, on 15 April 1832. He was the son of United States Congressman William W. Irwin and Frances Everallyn Rose Irwin. He was also the great-great step-grandson of Benjamin Franklin through his step-mother, Sophia Arabella Bache.
Early career
Irwin was appointed as a midshipman on 9 September 1847 and immediately went to sea, being attached to the frigate in the Home Squadron from 1847 to 1848, to the frigate in the Mediterranean Squadron from 1849 to 1850, and to the frigate on the African Slave Trade Patrol off the west coast of Africa from 1851 to 1853. He was promoted to passed midshipman on 10 June 1853. Assigned to the sidewheel steamer in the Home Squadron from 1854 to 1856, Irwin was promoted to master on 16 September 1855 and then to lieutenant on the same day. His next assignment was with the United States Coast Survey from 1857 to 1858. He then served aboard the frigate in the Home Squadron from 1859 to 1860.
After the Civil War, Irwin was assigned to special duty at Philadelphia from 1866 to 1867 and was promoted to commander on 25 July 1866. He then returned to sea, serving in the North Atlantic Squadron from 1868 to 1871, in command successively of the steamer in 1868, the steamer from 1868 to 1870, and the screwgunboat from 1870 to 1871. After spending 1872 on duty at League Island in Philadelphia, Irwin was commanding officer of the sailing frigate, then operating as a training ship, from 1873 to 1875. He was promoted to captain on 15 May 1875, and commanded the screw steamer, flagship of the Pacific Station, from 1875 to 1879. Irwin then began a lengthy series of shore tours, beginning with an assignment at Mare Island Navy Yard in Vallejo, California, from 1879 to 1883, followed by special duty in 1884 and a tour as President of the Board of Inspection, California, from 1884 to 1888, during which he was promoted to commodore on 4 March 1886. He was idle, awaiting orders, from 13 December 1889 to 12 July 1890, when he assumed duties as a member of the Board of Inspection and Survey. He was promoted to rear admiral on 19 May 1891. Departing the Board in June 1891, Irwin finally returned to sea when he assumed command of the Asiatic Squadron on 7 June 1891. He arrived in Honolulu, Hawaii, suddenly and unexpectedly on 6 November 1893 to replace Commodore Joseph S. Skerrett there as commander-in-chief of the Pacific Squadron; Skerrett traded places with Irwin, taking command of the Asiatic Squadron. Irwin soon became involved in the "Black Week" crisis of December 1893-January 1894, during which war nearly broke out between the United States and the Provisional Government of Hawaii. Irwin was placed on the Retired List on 15 April 1894 upon the reaching the mandatory retirement age of 62. He hauled down his flag for the final time aboard the protected cruiser at Honolulu the following day.
Retirement and death
In retirement, Irwin resided in Washington, D.C., where he died at his home late on the evening of 28 July 1901 after an illness of several months. He left behind his wife, a daughter, and a son, also named John Irwin, who at the time was paymaster aboard the training ship.