Dry, incoming air is blown across the inner surface of the visor from a part called a "spray bar". Thin-film heaters and chemical agents have also been used, to less success.
Although water vapor in exhaled air can cause fogging, the greatest source of water vapor is sweat. The problem is more common during physical activities such as spacewalks than when the astronauts are seated. The development of liquid cooling undergarments has significantly solved the problem.
Early Suits
Defogging goes all the way back to the first aviation pressure suit, made by B.F. Goodrich and worn by Wiley Post, enabling him to be the first person to fly above the tropopause and to discover the jet stream. The glass of the helmet was defogged by the dry, incoming air:
Oxygen entered through a port
just to the left of the window (Post had the
patch over his left eye) to defog the glass. An
outlet to the right of the window vented the
helmet. A valve, attached to a regulator and a
pressure gauge, just below the left inner knee
controlled outflow from the suit.
Dressing for Altitude: U.S. Aviation Pressure Suits from Wiley Post to Space Shuttle, p. 33
In the 1930s, an aviation pressure suit made for the French Navy used an air gap between two layers of glass, plus an electric heating system, to defog the glass. A German pressure suit of the same era also used electric heaters.
The David Clark model 12 suit worn by Scott Crossfield when flying for NACA used a face mask, with separate nose/mouth and eye compartments to prevent fogging.
NASA test pilot Joseph Walker tested the A/P22S-2 full-pressure suit in 1961. Made by the David Clark Company, it became the standard U.S. Air Force flight suit, and its basic design would evolve into many of NASA's spacesuits. It introduced the "spray bar", a metal or plastic tube around the circumference of the visor panel, with holes that blew incoming dry air onto the visor:
The breathing regulator and
all plumbing were installed inside the helmet
shell, with a spray bar around the periphery
of the visor that defogged the visor.
Dressing for Altitude, p. 266
Mercury
The Mercury spacesuits, derived from the Navy Mark IV made by Goodrich, were an outlier in that they did not blow air onto the helmet:
The air flowed through a series of
Trilok ducting that was integral to the torso
and exited at the wrists, ankles, crotch, and
periphery of the neck ring. It then flowed into
the body of the suit to remove excess moisture
and exited the suit through the exhaust port,
into the cockpit. In addition to ventilating the
suit, this air also pressurized it when needed.
Dressing for Altitude, p. 230
I find no evidence of the Mercury helmets fogging, nor any effort made to defog them. The astronauts were largely sessile, not performing activities that made them sweat. The visor also could flip open, and it seems that many of the astronauts simply left the visor open.
Gemini
A suit based on the Air Force A/P22S-2 by David Clark Company won a competition to become the Gemini spacesuit. The helmet inherited the spray bar, which was adequate for defogging when the astronauts were seated. However, liquid cooling undergarments were not yet invented, so the astronauts tended to overheat and sweat during intense physical activity, leading to fogging of the helmet. This was particularly bad during the spacewalk on Gemini 9A:
Cernan began the slow climb to the rear of the spacecraft, where the AMU was stored. While he was disconnecting himself from the capsule umbilical and hooking up to the backpack, his heart rate rose to about 155 beats per minute. He later described his spacesuit as having "all the flexibility of a rusty suit of armor", which made everything take much longer than expected. The lack of hand and foot holds also made him unable to gain any leverage, which made it hard to turn valves or even to perform any basic movements. While making the connections, Cernan became very tired. During this portion of the EVA, his pulse soared to about 180 beats per minute; the flight surgeon on the ground feared he would lose consciousness. As he sweated, his visor began to fog. He rubbed his nose against the visor to clear a spot so he could see.
Wikipedia
The Gemini suit became the basis for the David Clark S1030 suit, used in the SR-71 Blackbird spy plane. A gold film was tried as a visor heater, but it was discontinued due to problems with reflections. In the following picture, item #23 is the spray bar:
Apollo
A variant of the S1030 suit called the A1C was worn by the astronauts in the Apollo 1 fire. The death of the astronauts resulted in a reconsideration of the spacesuits.
The eventual Apollo suit (model A7L) was manufactured by International Latex Corporation, with Hamilton Standard as a subcontractor for the life-support equipment. Incoming dry air was blown onto the inner surface of the helmet to prevent fogging:
The ventilation system provides for two modes of operation, EV and IV. In the
EV mode, all inlet gas flow is directed to the helmet for respiration and helmet
defogging. The gas flow then travels over the body to the extremities, where return ducting routes the flow to the suit outlet. In the IV mode, the gas flow is split, with part of the gas flow going into a torso duct and directly over the body and the remaining gas going to the helmet.
Apollo Experience Report: Development of the Extravehicular Mobility Unit, NASA Tech Note D-8093, p. 10
Exhaled air was returned by umbilical to the cabin environmental system, or (if on an EVA) the portable life-support system. In either case, the carbon dioxide scrubbers also removed moisture from the air. After oxygen was added, dry air was returned to the suit. Apollo spacesuits also had liquid cooling undergarments, which were very effective in preventing sweating.
There was also a spacesuit repair kit, which included a defogging chemical (but no reports of it being used):
The fifth pouch contains five applicator pads saturated with a
cleaning and defogging solution.
Apollo Operations Handbook Extravehicular Mobility Unit, p. 2-89
Space Shuttle
All of the intravehicular suits used for launch and landing of the Space Shuttle were derived from the S1030 suit, itself derived from the Gemini suit:
- The S1030A was the Ejection Escape Suit, used on STS-1 to 4.
- The S1032 was the Launch Escape Suit, used on STS-26R through STS-88.
- The S1035 was the Advanced Crew Escape Suit, used on STS-64 and later.
In each, the visor can be opened; many astronauts never closed their visors. Incoming air is blown into the helmet through a spray bar. The air then continues through one-way valves in the neck dam, pressurizing the body of the suit. A pressure regulator then expels the air into the cabin.
A different suit was used for EVAs: the Extravehicular Mobility Unit. Again, incoming dry air is first blown onto the helmet surface:
The circulating oxygen enters the
suit through a manifold built into the Hard Upper
Torso. Ducting carries the oxygen to the back of the
space helmet, where it is directed over the head and
then downward along the inside of the helmet
front. Before passing into the helmet, the oxygen
warms sufficiently to prevent fogging of the visor.
As the oxygen leaves the helmet and travels into the
rest of the suit, it picks up carbon dioxide and
humid ity from the crew member’s res pirat i on.
More humidity from perspiration, some heat from
physical activity, and trace contaminants are also
picked up by the oxygen as it is drawn into the
ducting built into the Liquid Cooling-and-
Ventilation Garment. A centrifugal fan, running at
nearly 20,000 rpm, draws the contaminated oxygen
back into the PLSS at a rate of about 0.17 cubic
meters per minute, where it passes through the
Contaminant Control Cartridge.
Suited for Spacewalking, p. 27
This is the only instance I have found of pre-heating the air. I'm not sure if it is done electrically or by the astronaut's body heat. Directly heating the helmet by wires or coatings seems to no longer be done, because of the impact on vision.
An antifog chemical is also applied as part of EVA preparations:
Next, several simple tasks are performed.
Antifog compound is rubbed on the inside of the
helmet. A wrist mirror and a small spiral-bound
27-page checklist are put on the left arm of the
upper torso.
ibid p. 23
I haven't found any examples of special coatings. I don't know that the defogging chemicals are, but the same wipes are used to clean the helmets, so it might simply be some kind of alcohol.