Is there formaldehyde in beer? If there is, what purpose does it serve?
tl;dr—Yes, but only at safe levels.
Formaldehyde was detected in beer, at safe levels, as far back as 1983:
A simple procedure was developed for the determination of formaldehyde in samples of beer and soft drinks. [...] Levels of formaldehyde found were in the low mg/kg range. Detection limits were less than 0.1 mg/kg of sample.
A more recent study summarizes how China came under scrutiny, but also how industry standards have changed since (emphasis mine, hereon):
In 2005, various Chinese newspapers reported that formaldehyde was detected in 95% of the samples of Chinese commercial bottled beers tested in the course of a journalistic investigation. The addition of formaldehyde during mashing is allowed in China, and it is believed to improve the clarity of the resulting wort and beer and the colloidal stability of the latter. Nevertheless, the hygienic standard for fermented alcoholic beverages in China was revised, to stipulate that the formaldehyde content of the finished beer must not exceed 2 mg/L.
From the abstract of the same paper,
Beers brewed commercially in China have been surveyed for the presence of a number of potential contaminants, including benzene, trihalomethanes and formaldehyde. [...] Formaldehyde was measured in 29 beers (including 7 imported brands) using solid-phase microextraction with on-fiber derivatization. Formaldehyde levels were between 0.082–0.356 mg/L. None of the beer samples exceeded WHO drinking water criteria for benzene, trihalomethanes or formaldehyde.
The researchers compared their results to existing literature, which they found were similar:
Donhauser and co-workers examined beers from Europe, using a HPLC method, and showed that 65% of them contained detectable formaldehyde, although in many the level was close to the detection limit of 0.2 mg/L. More recently, the South Korean Food and Drug Administration has analysed imported beers (13 from China and 4 from Germany). They found that the average content of formaldehyde was 0.132 mg/L, which was compatible with food safety legislation.
(I couldn't find a free link to the above-referenced material, only a citation.)
Apparently, formaldehyde does appear naturally in the brewing process (though, again, I couldn't find the study, only another citation):
Borchert has confirmed that formaldehyde can be formed naturally in the brewing process, thus beers can contain up to 0.1 mg/L of formaldehyde, even when none is used in the brewery.
Anyway, formaldehyde no longer seems preferred as a clarification agent, as a substitute exists:
To meet consumer expectations and to avoid further problems, more and more breweries now choose PVPP as a replacement product for the clarification of wort and beer.
Formaldehyde can be used as a cheap clarification agent (making the beer clear; irish moss is a safe additive used for the same purpose). However, as it's a known carcinogen, it should be used very minimally.
TLDR: It's not widely used, and its use is in decline. Here's a reasonably well-sourced article on it.
It was hard to find any good sources on it, but:
- Various articles and blog posts seem to indicate there may be some in a few Chinese beers.
- Most beers with formaldehyde have below the WHO safety limit, and so are fine to drink.
- Some sources seem to say that formaldehyde may occur naturally in some brewing processes, but only in trace (and safe) amounts.
There might be trace amounts of it due to the oxidization of methanol from partially fermented sugars. But unless it is added to beer, not enough to be significant as opposed to other compounds that are present.