The foreign body response is an immune-mediated reaction that can lead to the failure of implanted medical devices and discomfort for the recipient. There is a critical need for biomaterials that overcome this key challenge in the development of medical devices. Here we use a combinatorial approach for covalent chemical modification to generate a large library of variants of one of the most widely used hydrogel biomaterials, alginate. We evaluated the materials in vivo and identified three triazole-containing analogs that substantially reduce foreign body reactions in both rodents and, for at least 6 months, in non-human primates. The distribution of the triazole modification creates a unique hydrogel surface that inhibits recognition by macrophages and fibrous deposition. In addition to the utility of the compounds reported here, our approach may enable the discovery of other materials that mitigate the foreign body response.