Wood-based N, P co-doped graphene oxide modified foam (N, P-GCF) was prepared by liquefaction, resinization, foaming, carbonization and CO2 activation by liquefaction, resinization, foaming, carbonization and CO2 activation. The surface morphology, crystal structure, chemical properties and hydrophilic properties of N, P-GCF were analyzed by SEM, XRD, Raman, XPS and contact angle measuring instrument, and the effects of N, P-GCF on pore structure, electrochemical properties and capacitance deionization (CDI) were explored by changing the addition amount of NH4H2PO4. The results showed that after GOs modification and NH4H2PO4 doping, the pore size decreases and the disorder increases. N, P-GCF has a hierarchical pore structure. When the doping amount of NH4H2PO4 was 2 g, it had the highest specific surface area of 2684.11 m²/g, total pore volume of 1.42 cm³/g and mesoporosity of 49.45%, and the mass fractions of N and P were 2.48% and 3.46%, respectively. N elements mainly exist in the form of N-5, N-6 and N-X, and P elements are mainly P-C and P-N. Compared with CF, N, P-GCF2.0 has excellent wettability and mechanical properties. In the three-electrode system of 1 mol·L NaCl electrolyte, the specific capacitance of N, P-GCF2.0 is 256.48 F/g at a current density of 1 A/g, and the specific capacitance retention rate is 72.51% when the current density increases to 15 A/g. Under the initial NaCl solution of 500 mg/L and the working voltage of 1.2 V, N, P-GCF2.0 had the best desalination capacity (29.97 mg/g) and salt adsorption rate (1.84 mg/(g·min)), and the retention rate of desalination capacity was 90.12% after 10 cycles, indicating good cycling stability. [ABSTRACT FROM AUTHOR]