In order to reduce the migration and availability of heavy metals in domestic sludge and improve its utilization rate, the residual sludge of a municipal domestic sewage treatment plant was taken as the research object, the sludge by composting alone was set as the control group, and the earthworms and different proportions of corn straw charcoal (0%, 2%, 4%, 6% and 8%) were added, to study the time variation of heavy metal concentrations and their effective state in sludge under the condition of straw charcoal assisted earthworm composting. The results showed that with the increase of composting time (0-30 d), the pH and TN concentrations of sludge first increased and then decreased, the TOC concentration gradually decreased, the EC concentration first decreased and then increased, and the TP and TK concentrations gradually increased. At the end of composting, the pH, TOC and TN concentrations decreased by 6.38%, 20.24% and 13.44% on average compared with the initial values, respectively. The concentrations of heavy metals Cd, Zn and Pb decreased first and then increased, while the concentrations of Cu, Ni and Cr increased first and then decreased. The effective concentrations of heavy metals Cd, Cu, Ni and Zn decreased first and then increased, and the effective concentrations of Cr and Pb increased first and then decreased. After 10 days of composting, the effective concentrations of Cd, Cu, Ni and Zn decreased the most compared with the initial values, with an average decrease of 40.99%, 30.65%, 16.23% and 3.17%, respectively. The addition of straw carbon could improve the weak acid environment of sludge, increase the concentration of TK, and decrease the concentrations of EC, TOC, TN and TP. The concentrations of heavy metals in sludge (except Pb) and their effective state concentrations (except Cu and Pb) decreased with the increase of the proportion of carbon added to straw. Through correlation and stepwise regression analysis, it was concluded that straw charcoal assisted earthworm composting mainly affected the effective concentration of heavy metals by changing the sludge pH and the concentrations of EC, TOC and TP, and the addition of 8% corn straw charcoal had the best effect on reducing the concentrations and effective concentrations of heavy metals in the sludge.