Water-energy nexus, or referred to as the interdependence between water and energy, is increasingly highlighted as as an important global issue for environmental sustainability. Energy-efficient separation technologies that can remove ions from aqueous solutions have attracted great attention for desalination and water treatment. Recently, capacitive deionization (CDI) is a promising electrochemical technology to separate salt ions or charged contaminants from water. In CDI, ions can be temporarily held within the charged nanopores of carbon electrodes by electrical double-layer formation. CDI has several operational advantages including low-energy consumption, low fouling potential, high water recovery, and environmental friendliness. To further improve the performance of CDI, ion-exchange membranes can be positioned in front of each carbon electrode to avoid co-ion effects: a configuration called membrane capacitive deionization (MCDI). As demonstrated, MCDI is more competitive in treating brackish water (total dissolved salt < 4000 ppm) to deliver fresh water due to the relatively low energy input. Most recently, a scaled-up MCDI stack was developed to desalinate the bio-treated effluent of municipal wastewater treatment plant. The MCDI can continuously produce remarkably high-quality reclaimed water that meet the water quality standard for industrial reuse. In addition, CDI shows great potentials for remediation of arsenic-contaminated groundwater, selective removal of nitrate and recovery of rare metal ions (e.g., indium) from wastewaters. Therefore, the electrochemical processes with nanoporous carbon electrodes enable a wealth of environmental applications, ranging from desalination, industrial water remediation to recovery of elements.