Two kinds of aqueous phases (AQ230 and AQAm230) prepared from hydrothermal carbonization of sewage sludge in pure water and aqueous ammonia, respectively, were separately hydrothermally cocarbonized with cellulose at 260, 280 and 300 °C. The N-heterocyclic compounds in the aqueous phase promoted the N content of the hydrochars while reducing their O content through a possible conversion of –CO into –CN-/C–N. With both AQ230 or AQAm230, increasing the temperature improved the incorporation of N into the aromatic rings, while the fluctuation in total N content in the hydrochars from each aqueous phase was not as remarkable. After KOH-activation of the hydrochars, the average pore diameter of the derived N-doped carbons (NCs) exhibited an increasing trend with increasing O/N ratio, especially at lower N-doping. A three-dimensional approximation confirmed that the specific surface area decreased when the C, N, and O content were high. In a three-electrode system, NC230280 exhibited the best performance, with a specific capacitance of 219.91 F g−1 at 0.25 A g−1 (63.64% retention at 20 A g−1), the lowest internal resistance (0.51 Ω), and a small time constant (0.49 s). In a two-electrode system, NC230280 exhibited 176.72 F g−1 at 0.25 A g−1 (59.08% retention at 20 A g−1), and a maximum energy density of 6.14 Wh⋅kg−1 was reached at a power density of 64 W kg−1 (5.86 Wh⋅kg−1 was still maintained at 518.07 W kg−1). The results reveal that, in addition to the surface properties, the type of precursor and the elemental composition of the NCs also influence the capacitance performance.