Membrane capacitive deionization (MCDI) is a cost-effective desalination technique known for its low energy consumption. The performance of MCDI cells relies on the properties of electrode materials. Activated carbon is the most widely used electrode material. However, the capacitive carbon available on the market is often expensive. Here, we developed hierarchically porous biochar by combining carbonization and activation processes, using easily acquired aerobic granular sludge (AGS) from biological sewage treatment plants as a precursor. The biochar had a specific surface area of 1822.07 m2 g-1, with a micropore area ratio of 58.65% and a micropore volume of 0.576 cm3 g-1. The MCDI cell employing the biochar as electrodes demonstrated a specific adsorption capacity of 34.35 mg g-1, comparable to commercially available activated carbon electrodes. Our study presents a green and sustainable approach for preparing highly efficient, hierarchically porous biochar from AGS, offering great potential for enhanced performance in MCDI applications.& COPY; 2023 Published by Elsevier B.V. on behalf of Chinese Society for Environmental Sciences, Harbin Institute of Technology, Chinese Research Academy of Environmental Sciences. This is an open access article under the CC BY-NC-ND license (http://creativecommons.org/licenses/by-nc-nd/4.0/).