Engineers have had to come up with some special ways to create oxygen in the vacuum of space . Here's how astronauts breathe in space .

How to Breathe in Space
In 1997, a fire broke out on the Mir space station, the precursor to the International Space Station. The culprit was the spacecraft’s oxygen generator, which burned solid lithium perchlorate cylinders to create a breathable atmosphere. Material from a rubber glove, possibly left inside the generator during assembly, caught fire when the machine was activated, creating a blaze that lasted about 14 minutes before it was completely extinguished.
Although no crew members were injured, the accident highlighted the difficulty and safety risks of providing astronauts with a constant supply of oxygen during their time in orbit. Like onboard water purification systems, the equipment that creates this life-saving supply has evolved significantly since the Space Race began in the 1960s.
Smoke and Mir
The Apollo program, which included the 1969 mission that first landed humans on the moon, used an Environmental Control Unit (ECU) to maintain a pure oxygen atmosphere in the command module. The ECU was equipped with lithium hydroxide and activated carbon cartridges to filter carbon dioxide from astronauts’ breath and absorb odors. It also produced water and maintained cabin temperature, allowing up to three astronauts to survive in space for 14 days.

The Mir space station, launched in 1986, was designed for longer space missions and produced oxygen through a chemical reaction. A generator ignited lithium perchlorate tanks the size of large spray cans, releasing oxygen as they burned. One of these “oxygen candles” provided enough breathing air for a crew member for a day, but the system showed its weakness in a rubber glove incident.
After that accident, aerospace engineers stopped using chemical reactions to create oxygen in space. The ISS replaced Mir in the early 2000s and was equipped with a safer ECU based on electrolysis, which uses a generator to split water molecules through a proton exchange membrane into oxygen and hydrogen. While the oxygen produced through this process is released into the atmosphere, the hydrogen is combined with carbon dioxide exhaled by the crew to create drinking water and methane. Currently, the methane is vented from the station, but it could one day be useful for onboard bio-manufacturing processes. The ISS also carries a Mir model to create oxygen as a backup.
Life in a backpack
Providing oxygen to astronauts while they're inside the spacecraft is one thing. Doing so when they leave the spacecraft for spacewalks—to test equipment, conduct experiments, or perform repairs outside—is another.

A modern spacesuit designed for spacewalks, also known as an Extra-Vehicular Mobility Unit (EMU), is equipped with a backpack that houses various life support systems. Among other functions, it supplies oxygen to the astronaut's helmet while filtering out carbon dioxide. The suit also protects their bodies from the potentially life-threatening forces of the vacuum they venture into.
Even before entering the EMU, astronauts spend hours breathing pure oxygen inside a compressed air capsule to minimize the chance of becoming comatose. According to former astronaut Mike Mullane, the command module maintains an atmospheric pressure of 14.7 pounds per square inch (psi), which is about the same as Earth at sea level, but the pressure in a spacesuit is just five psi. Astronauts must “pre-breathe” pure oxygen to remove nitrogen from their bodies and prevent the formation of gas bubbles in their blood—the cause of a condition called compressed air sickness—before spacewalking. Otherwise, excess nitrogen bubbles can clog blood vessels and cause tissue damage, leading to joint pain, headaches, muscle weakness, paralysis, fatigue, and confusion, among other symptoms.
The importance of spacesuits is perhaps best illustrated by what would happen without them. Astronauts would instantly pass out from lack of oxygen, while the vacuum would cause their blood and bodily fluids, which evolved to adapt to Earth’s atmospheric conditions, to freeze, boil, and rupture.
The conditions of space make a simple act like breathing a complex, potentially fatal challenge. Fortunately, it's not something science can't handle.