The present work introduces a new method for the recycling of waste flocculation sludge to prepare electrode materials for supercapacitor. Hazardous azo dye was removal from textile dying wastewater by a new chitosan-based flocculant, and the generated dye sludge flocs was used as a nitrogen-containing precursor for the fabrication of N-doped carbon materials. The influence of azo dye on specific surface areas, nitrogen content, pore evolution of the resulting products and their electrochemical performance were investigated in detail. The results demonstrated a dual role of azo dye worked as both a nitrogen resource and pore-forming agent. The resulting N-doped carbon nanosheets derived from azo dye flocs demonstrated high electrochemical capacitance and good stability for supercapacitor electrode, which is attributed to the unique nitrogen doping, higher specific surface area and efficient charge transfer ability.