This paper studies the economic feasibility of installing hydrogen networks for decarbonizing heat in urban areas. The study uses the Heat Infrastructure and Technology (HIT) spatially resolved optimization model to trade-off energy supply, infrastructure, and end-use technology costs for the most important heat-related energy vectors: gas, heat, electricity, and hydrogen. Two model formulations are applied to a UK urban area: one with an independent hydrogen network and one that allows for retrofitting the gas network into hydrogen. Results show that for average hydrogen price projections, cost-effective pathways for heat decarbonization toward 2050 include heat networks supplied by a combination of district-level heat pumps and gas boilers in the domestic and commercial sectors and hydrogen boilers in the domestic sector. For a low hydrogen price scenario, when retrofitting the gas network into hydrogen, a cost-effective pathway is replacing gas by hydrogen boilers in the commercial sector and a mixture of hydrogen boilers and heat networks supplied by district-level heat pumps, gas, and hydrogen boilers for the domestic sector. Compared to the first modeled year, CO2 emission reductions of 88% are achieved by 2050. These results build on previous research on the role of hydrogen in cost-effective heat decarbonization pathways.