Low-grade heat energy (below 100 °C) is abundantly available in the natural environment, yet effective utilization remains challenging. Liquid-state thermocells, also known as thermo-electrochemical cells or thermogalvanic cells, have emerged as promising solution for converting low-grade heat into electrical energy due to their high Seebeck coefficients (mV·K–1). However, traditional liquid-state thermocells suffer from the issue of liquid leakage caused by frequent cooling or heating during operation. Here in this work, we propose thermogalvanic hydrogels through introducing redox ions into hydrogel framework. The thermoelectric performance of the proposed hydrogel is highly dependent on the ion concentration, which is attributed to the confined ion transportation in micro/nano channels caused by the salting out effect. After the optimization of thermoelectric parameters, a Π-shaped thermocell composed of three p-n pairs is fabricated to harvest low-grade body heat energy. An open-circuit voltage of 163 mV, a short-current density of 0.7 mA·m–2 and a maximum power density of 26.7 μW·m–2 are achieved at a temperature difference of 30 K. To further demonstrate the practical potential, the thermoelectric generator is integrated with a lactic acid sensor to sensitively detect the lactic acid concentration without any external power supplies.