On this page
Diazomethane shows up in organic chemistry as a reagent above an arrow, and it is easy to memorise the product without knowing why it forms. This guide covers the two reactions you are most likely to meet and why chemists treat CH2N2 with so much respect.
Diazomethane was discovered by the German chemist Hans von Pechmann in 1894, according to the Wikipedia article on diazomethane, which describes the molecule as linear, C=N=N.
What does diazomethane do to a carboxylic acid?
Carboxylic acids react with diazomethane to give methyl esters, with nitrogen gas as the by-product, as the LibreTexts organic chemistry text_Complete_and_Semesters_I_and_II/Map:_Organic_Chemistry_(Wade)/21:_Carboxylic_Acids/21.07:_Methyl_Ester_Synthesis_Using_Diazomethane) explains. The mechanism has two steps:
Acid-base step: the carboxylic acid gives its proton to the carbon of diazomethane. You now have a carboxylate ion (RCOO-) and a methyldiazonium ion (CH3-N2+).
SN2 step: the carboxylate attacks the CH3 group, and N2 leaves.
The second step is fast because N2 is one of the best leaving groups in chemistry. It is a very stable molecule, and it escapes as a gas, so the reaction cannot easily run backwards. Overall: RCOOH + CH2N2 gives RCOOCH3 + N2.
How does diazomethane expand a ring by one carbon?
Diazomethane can also add a CH2 unit to a ketone. The classic example: cycloheptanone is prepared by ring expansion of cyclohexanone with diazomethane as the methylene source, a route described on Wikipedia's cycloheptanone page.
Here is the logic, step by step:
The carbon of CH2N2 is nucleophilic. It attacks the carbonyl carbon of cyclohexanone, giving an alkoxide (O-) next to a CH2-N2+ group.
One of the ring C-C bonds next to the carbonyl carbon migrates onto that CH2, pushing out N2.
The oxygen re-forms its C=O bond. The ring now has seven atoms instead of six.
The diagram at the top shows both ideas: the acid gaining a methyl group, and the six-membered ring gaining one CH2 (the highlighted carbon).
Why is diazomethane handled with such care?
The US National Institute for Occupational Safety and Health describes diazomethane as a yellow gas with a musty odour in its NIOSH Pocket Guide entry. Three facts from that page explain the caution:
Its recommended exposure limit is 0.2 ppm as a time-weighted average, and the level immediately dangerous to life or health is 2 ppm.
It may explode violently on heating, on exposure to sunlight, or on contact with rough edges such as ground glass.
It irritates the eyes and can cause cough, shortness of breath, chest pain and pulmonary oedema.
Because it is so reactive, diazomethane is made in situ and used straight away rather than stored, as the LibreTexts chapter_Complete_and_Semesters_I_and_II/Map:_Organic_Chemistry_(Wade)/21:_Carboxylic_Acids/21.07:_Methyl_Ester_Synthesis_Using_Diazomethane) notes. A common substitute, trimethylsilyldiazomethane, is a relatively stable liquid and easier to handle, but it is still highly toxic and has been linked to the deaths of at least two chemists, according to Wikipedia's trimethylsilyldiazomethane page.
For a student, the lesson is simple: diazomethane belongs on paper, never in a home or school experiment.
How do you solve a diazomethane question in an exam?
Use this four-step check whenever CH2N2 appears above an arrow.
Find the most acidic hydrogen. A COOH group reacts with CH2N2 readily; that is where the methyl group goes.
Look for a ketone in a ring. If the question is about ring size, expect one extra carbon next to the C=O.
Write N2 as a product. It is the leaving group in both reactions.
Balance atoms to check yourself.
Worked example: benzoic acid (C7H6O2) reacts with diazomethane (CH2N2). The acid protonates CH2N2, benzoate attacks CH3, and N2 leaves. The product is methyl benzoate, C6H5COOCH3.
Check the atoms. On the left: C 7 + 1 = 8, H 6 + 2 = 8, O 2, N 2. On the right, methyl benzoate is C8H8O2 and nitrogen gas is N2. Everything balances, so the answer holds.
If ideas like nucleophiles and leaving groups still feel shaky, the Fermi Concept Library gives every chemistry concept its own lesson and its place in the map. To practise, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer, which helps when you got the product right but the mechanism wrong.
Next time you see CH2N2, follow the nitrogen: find where N2 leaves, and the product follows.



