Vilsmeier-Haack Reaction
Description: The Vilsmeier-Haack reaction is a way of installing an aldehyde on an electron-rich aromatic ring, using an electron-poor reagent (the Vilsmeier reagent) generated from DMF (N,N-dimethylformamide) and phosphorus oxychloride (POCl3).

Notes: The reaction does not work on benzene itself; the aromatic ring has to be quite electron-rich and have strong pi donors such as OCH3 and NR2. It also works well for electron-rich heterocycles such as pyrrole, furan, thiophene and indole.
See Also: Friedel-Crafts acylation, Reimer-Tiemann reaction,
Examples:

Notes:
Note that the aromatic rings are all quite electron-rich, such as N,N-dimethylaniline (Example 1) and anisole (Example 2). Pyrrole and N-methylpyrrole (Example 3) are selective for the 2- position, as is benzofuran (Example 4).
The usual source of the aldehyde (-CHO) is N,N-dimethylformamide (DMF) but other formamides can be used, such as N-methylanilinamide (example 5) which works with anthracene.
Thiophene (Example 6) tends to be selective for the 2-position, but indole (Example 7) is selective for the 3-position.
Mechanism:
The first step here is just thinking about the resonance structure of N,N-dimethylformamide (Step 1, arrows A and B).
In this reaction it’s the oxygen of DMF that is the nucleophile for the next step.
Part 1: Resonance Structure of DMF

OK. Now that we have our nucleophile identified, the first step is addition of that nucleophile to the electrophile POCl3 (Step 2, arrows C and D) to give the addition product.
Next, chloride ion is eliminated to re-form the P=O bond (Step 3, arrows E and F). Then the chloride ion acts as a nucleophile to attack the electrophilic carbon atom (Step 4, arrows G and H) to give the addition product, which then eliminates chloride (Step 5, arrows I and J) to give the Vilsmeier reagent . In this case Cl2P(O)O(-) is the counter-ion.
Part 2: Formation of Vilsmeier Reagent

OK, now that we have our Vilsmeier reagent, it can now act as an electrophile in the presence of an electron-rich aromatic ring. The first step is attack of the ring on the Vilsmeier reagent (Step 1, arrows K and L) to form the new C-C bond, which then undergoes elimination to restore aromaticity (Step 2, arrows M and N).
Next, chloride ion is eliminated to form the new iminium ion (Step 3, arrows O and P).
At this step the iminium undergoes hydrolysis by water. These steps haven’t been drawn out but it’s covered here [Hydrolysis of imines].
The final product is a “formylated” aromatic ring with a new -CHO bond (an aldehyde).
This sequence is the “Vilsmeier-Haack” reaction.
Part 3: Vilsmeier-Haack Reaction

Notes: We showed POCl3 here, but there are many other electrophiles that can be used in the formation of the Vilsmeier reagent. A common one is oxalyl chloride (COCl)2 , which is commonly used for formation of acid halides from carboxylic acids.
For many more examples, definitely check out the two reviews of the Vilsmeier-Haack reaction in Organic Reactions.
(Advanced) References and Further Reading
[references]