We know that base-catalyzed halogenation of aldehydes and ketones replaces all the ɑ hydrogens:

The reaction is difficult to stop at monohalogenation because the product, after the first step, is more reactive than the starting carbonyl, and therefore keeps reacting until all the protons are replaced by the halogen.
An interesting situation occurs when methyl ketones are halogenated. The intermediate product here is a trihalogenated ketone and these three halogens make it very reactive towards a nucleophilic acyl substitution since the leaving group is going to be well-stabilized:

In the last step, the deprotonation of the carboxylic acid results in a haloform which is the basis of the reaction name.
The haloform reaction is mostly known for the reaction of methyl ketones with iodine.
While the products of chlorination and bromination are chloroform (CHCl3) and bromoform (CHBr3) respectively, iodination forms a bright yellow solid iodoform (CHI3) which is an indicator for methyl ketones or alcohols that are oxidized to methyl ketones in the presence of iodine:

The Applications of Haloform Reaction
The haloform reaction is not only a test reaction for methyl ketones but can also be used for functional group transformations of carboxylic acid derivatives. For example, we can use it for the conversion of methyl ketones to amides:

It is worth mentioning that the haloform reaction works not only for methyl ketones but for many precursor alcohols which are oxidized in situ to the corresponding methyl alcohol. For example, we can convert secondary alcohols to esters and other derivatives of carboxylic acids using the haloform reaction:

Next, we will talk about the Hell–Volhard–Zelinski Reaction for the alpha halogenation of carboxylic acids.
Check Also
- Alpha Halogenation of Enols and Enolates
- The Haloform and Iodoform Reactions
- Alpha Halogenation of Carboxylic Acids
- Alpha Halogenation of Enols and Enolates Practice Problems
- Aldol Reaction – Principles and Mechanism
- Aldol Condensation – Dehydration of Aldol Addition Product
- Intramolecular Aldol Reactions
- Aldol Addition and Condensation Reactions – Practice Problems
- Crossed Aldol And Directed Aldol Reactions
- Crossed Aldol Condensation Practice Problems
- Alkylation of Enolates Alpha Position
- Enolate Alkylation Practice Problems
- Acetoacetic Ester Synthesis
- Acetoacetic Ester Enolates Practice Problems
- Malonic Ester Synthesis
- Michael Reaction: The Conjugate Addition of Enolates
- Robinson Annulation, Shortcut, and Retrosynthesis
- Claisen Condensation
- Dieckmann condensation – An Intramolecular Claisen Reaction
- Crossed Claisen and Claisen Variation Reactions
- Claisen Condensation Practice Problems
- Stork Enamine Synthesis
- Enolates in Organic Synthesis – a Comprehensive Practice Problem