William John Foster (13 January 1831 – 16 August 1909) was a politician and Supreme Court judge in colonial New South Wales, Attorney General from 1877 to 1878. Foster was born in Rathescar, County Louth, Ireland, the son of Rev. William Henry Foster of Loughgilly, County Armagh, and his wife Catherine, née Hamilton. Foster was educated at Cheltenham College, and at Trinity College Dublin, where he took the Vice-Chancellor's prize for Greek in 1850, also the composition prize in the same year, as well as honours in classics and mathematics. He left the university in 1851.