The invention discloses a carbon-based compound fertilizer and biomass gas co-production technology based on municipal sludge. The technology comprises the following steps: 1) dehydration; 2) crushing; 3) mixing: 53%-92% by mass of sludge particles, 1%-40% by mass of straw powder and 3%-8% by mass of a carbon sequestration additive are mixed, wherein the carbon sequestration additive contains diatomite, calcium oxide and magnesium ore powder; 4) drying; 5) granulation; 6) pyrolysis and gasification: biomass derived fuel particles are fed into a gasifier and subjected to pyrolysis and gasification under the micro-oxygen condition of air equivalent ratio being 0.18-0.25 at 600-800 DEG C, biomass mixed fuel containing part of purities is obtained, and carbon residues in the gasifier are discharged; 7) gas separation: wood tar and wood vinegar are removed from the biomass mixed fuel through purification, and the purified biomass mixed fuel is taken as gas fuel; 8), carbon-based compound fertilizer preparation: 40%-60% of the carbon residues, 12%-20% of a wood tar and wood vinegar mixed liquid, 20%-35% of inorganic nitrogen phosphorus and potassium fertilizer and 2%-5% of diatomite are mixed. Biomass in the municipal sludge and residues obtained after energy conservation treatment can be used efficiently, by means of the obtained compound fertilizer, soil granulation can be increased, the rate of utilization of the fertilizer by crops is increased, heavy metal components are solidified, secondary pollution to the environment is avoided, few resources are consumed, and the comprehensive economic benefits are increased.