A Chinese chef cooking a dish with cobra flesh was killed by the snake he had planned to eat — when the creature’s severed head chomped down on him first.

Peng Fan set the Indochinese spitting cobra’s head aside while chopping its body for a soup, the Mirror newspaper reported.

But when he tried to toss the reptile’s head in the trash 20 minutes later, it bit him, injecting him with its fast-acting venom.

Diners in his restaurant recalled hearing screams coming from the kitchen.

“Suddenly there was a lot of commotion,” one woman said. “We did not know what was happening . . . After we heard that, we did not continue with our meal.”

All reptiles can function for up to an hour without the rest of their bodies, an expert said.