Zwitterionic hydrogels such as those based on polycarboxybetaine (PCB) or polysulfobetaine (PSB) have potential for various biomedical applications, due to their biocompatibility and low biofouling properties. However, the poor mechanical properties of zwitterionic hydrogels developed to date remain a challenge, severely limiting their practical uses. To improve the mechanical properties without compromising their zwitterionic feature or biocompatibility, we designed a new class of zwitterionic hydrogels by introducing triazole moieties into the hydrogel monomers that could form energy-dissipating π-π stacking. Compared to conventional zwitterionic hydrogels, the triazole-zwitterionic (TR-ZW) ones exhibited similarly excellent antifouling properties, but were much more mechanically robust with higher stretchability (250% tensile strain), better compression-resistance (89% compressive strain and 65% compression for at least 10 cycles without any crack) and better folding-resistance. In addition, upon subcutaneous implantation in mice, the TR-ZW hydrogels induced significantly lower foreign body responses (FBR) (i.e. less fibrosis and more blood vessel formation relative to a poly(2-hydroxyethyl methacrylate) hydrogel control). As an example of their potential applications, we showed the use of the TR-ZW hydrogels for islet encapsulation and transplantation and demonstrated diabetes correction up to ~1 month in mice in the convenient subcutaneous site.