Efficient energy conversion using ions as carriers necessitates membranes that sustain high permselectivity in high salinity conditions, which presents a significant challenge. This study addresses the issue by manipulating the linkages in covalent-organic-framework membranes, altering the distribution of electrostatic potentials and thereby influencing the short-range interactions between ions and membranes. We show that a charge-neutral covalent-organic-framework membrane with β-ketoenamine linkages achieves record permselectivity in high salinity environments. Additionally, the membrane retains its permselectivity under temperature gradients, providing a method for converting low-grade waste heat into electrical energy. Experiments reveal that with a 3 M KCl solution and a 50 K temperature difference, the membrane generates an output power density of 5.70 W m