Methylation of carboxylic acid using diazomethane
NOTE: Important charges are shown throughout the animation except during the transition phase
Diazomethane methylates carboxylic acids because carboxylic acids readily protonate it, giving an extremely unstable diazonium cation. This compound is desperate to lose N2 and so it does with the N2 being substituted by the carboxylate anion. The carboxylate anion is in exactly the right position to carry out an SN2 reaction as shown above. Diazomethane methylation is a good way of making methyl esters from carboxylic acids.