Toxoids produced by tetanus and diphtheria bacteria are detoxified with formaldehyde, yet their antigen properties remain.
Source : Biological Science by Taylor
What does formaldehyde do ?
The toxins of both Clostridium tetani and Corynebacterium diphtheriae are so toxic that you cannot use them for immunization, since the amount needed for proper antibody production would kill the individuals. For that purpose the toxins are "de-toxified" by reacting them with formaldehyde which takes away the toxicity but the resulting toxoids are still immunogenic. This happens by the reaction of the formaledehyde with the free aminogroups of the sidechains of the amino acids to form azomethin groups. This changes the protein so much, that it cannot bind to glangliosides any more which renders it untoxic. The immune system can still recognize unmodified parts (for this 8-10 amino acids in one stretch are enough) and make antibodies.