Electrode materials with a deformation capability are vital to the development of flexible supercapacitors. However, the preparation of porous carbons with a deformability remains challenging. Herein, a compressible carbon foam has been successfully prepared using a polydopamine/melamine sponge (PDA/MS) as the precursor material. The porous structure of the carbon foam was controlled by using cetyltrimethylammonium bromide and K2CO3 as template and activating agent, respectively. The resultant PDA/MS-derived carbon foam (KDMC) has a three-dimensional network architecture and exhibits excellent compressibility. The specific surface area reaches ∼2890.0 m2 g-1. Furthermore, KDMC demonstrates outstanding capacitive performance, including excellent specific capacitance (365.6 F g-1, 0.5 A g-1), good rate capability (86.6% capacitance retention from 0.5 to 10 A g-1), and outstanding cycling stability (only 1.9% capacitance loss after 10,000 cycles). To further demonstrate the practical application potential of KDMC, a symmetric supercapacitor (KDMC//KDMC) was assembled with a PVA/KOH gel electrolyte. The symmetric device achieved an energy density of 10.44 W h kg-1. This work presents a robust method to prepare compressible electrode materials for high-performance supercapacitors.