About a decade ago Los Angeles–based software developer Lorna Herf decided to try her hand at oil painting. She and her husband, Michael, also a computer programmer, eventually installed bright fluorescent lights in their apartment's loft so that Lorna could paint at night and still have an accurate sense of what colors on the canvas would look like during the day. Late one evening Lorna descended to the living room, where computer screens were aglow. Now that she had become more attuned to differences in lighting, she noticed just how much the bright light from the computer screens clashed with the soft warmth of the incandescent bulbs that surrounded them. She remembers thinking the electronic screens were “like little windows of artificial daylight,” spoiling the otherwise gentle ambience of the room.

The tech-savvy couple engineered a crafty solution to minimize the discrepancy. They wrote some code to change the number and wavelength of the photons emitted by their computer screens as a day progressed. The Herfs' goal was to mimic natural shifts in ambient light as closely as possible, transitioning from the bright, bluish-white light characteristic of morning and afternoon sunshine to a dim, orange glow in the evening.

At first, they simply intended to harmonize the lighting scheme in their home. But they soon began to suspect that their new app, dubbed f.lux, might offer some health benefits as well. “After we'd been using it for a while, we started to notice it seemed easier to wind down at night,” Lorna recalls, making it easier to fall asleep when they turned off their electronic devices. They are not the only ones who have appreciated the calming effect. Since the Herfs released the program for free in 2009, f.lux has been downloaded more than 20 million times.

By following their aesthetic taste, the Herfs had stumbled on a curious twist in the way the body controls how we sleep. Researchers have known for several decades that strong light of any kind can suppress melatonin, the hormone the brain produces at night to induce sleepiness. But more recent studies show that blue light suppresses melatonin more effectively than any other visible wavelength, potentially leaving people more alert when they would otherwise start feeling drowsy.

As it happens, smartphones, laptops and all kinds of electronic screens have become brighter and bluer over the past couple of decades because of the addition of powerful blue LEDs. During the day, when blue light is already naturally plentiful, a little extra exposure from electronic screens should not make much of a difference to anyone's physiology. The problem is that people are increasingly staring into bright screens long into the night.

Nearly everyone in a survey conducted by the National Sleep Foundation in 2011, for example, used a television, computer, cell phone or similar device within an hour of going to bed at least a few nights a week. In 2014 the same organization determined that 89 percent of adults and 75 percent of children in the U.S. have at least one electronic device in their bedroom, with a significant number of them sending or answering texts after they had initially fallen asleep. Motivated by such research, engineers and computer programmers are trying out various solutions to keep an already sleep-deprived population from losing more zzz's because of their electronic devices. The solutions range from tinted eyeglasses to naturalistic lighting systems for the home and office.

“If people can figure out ways to simulate changes in sunlight across the day, that would be perfect,” says Christian Cajochen, head of the Center for Chronobiology at the University of Basel in Switzerland. “The ideal would be to have the same light throughout your home as outside of it.” It remains to be seen how effective these remedies are, however, especially when compared with simply shutting the devices off.

Too Much of a Good Thing

The light emanating from electronic devices was not always such a hindrance to restful sleep. The current state of affairs can be traced to the 1992 invention in Japan of the high-brightness blue LED. By combining the new blue LEDs with older green and red ones or coating blue LEDs with chemicals that reemit other wavelengths, technology manufacturers could generate full-spectrum white LED light for the first time. Because LEDs are much more energy-efficient than their fluorescent predecessors, they soon became ubiquitous in TVs, computer screens, tablets and certain e-readers, infusing homes and offices with much brighter blue light than ever before.

Researchers did not begin amassing concrete evidence that blue LEDs can disrupt sleep until about 15 years ago, but they have had a good idea of the probable mechanism for quite some time. Scientists had discovered back in the 1970s that a tiny brain region dubbed the suprachiasmatic nucleus helps to control the body's sleep cycles, alertness, temperature and other daily fluctuations. Studies showed that the suprachiasmatic nucleus prompts the brain's pineal gland to produce melatonin every evening.

Earlier this century biologists uncovered exactly how this signaling process happens. As it turns out, the missing link was a previously unknown type of light-sensitive cell in the human eye, distinct from the familiar rods and cones that are responsible, respectively, for night and color vision. This third so-called photoreceptor tracks the amount of blue light in the environment and reports back to the suprachiasmatic nucleus. Thus, when there is a lot of blue light (as when the sun is overhead), this particular photoreceptor prompts the suprachiasmatic nucleus to tell the pineal gland not to make much melatonin, and so we stay awake. When the sun begins to set, however, the amount of blue light diminishes, triggering a surge in melatonin levels, prompting us to fall asleep.

Among the studies offering evidence that screens with blue LEDs might confuse the brain at night is a 2011 investigation by the University of Basel's Cajochen and his colleagues. In that work, volunteers exposed to an LED-backlit computer for five hours in the evening produced less melatonin, felt less tired, and performed better on tests of attention than those in front of a fluorescent-lit screen of the same size and brightness. Similarly, for subjects in a 2013 study led by Mariana Figueiro of the Rensselaer Polytechnic Institute, interacting with an iPad for just two hours in the evening was enough to prevent the typical nighttime rise of melatonin. And in a two-week trial at Brigham and Women's Hospital in Boston, published in 2014, volunteers who read on an iPad for four hours before bed reported feeling less sleepy, took an average of 10 minutes longer to fall asleep and slept less deeply compared with those who read paper books at night. Cajochen and others have also shown that these effects are especially pronounced in teens and adolescents, for reasons that remain unclear.

In a New Light

Given the accumulating evidence that artificial screens in general and blue lights in particular spoil sleep, scientists have begun investigating various remedies. Several studies have shown that wearing orange-tinted plastic goggles, which filter out the blue light emanating from electronic devices, helps to prevent melatonin suppression. Similar glasses are now commercially available for as little as $8 or as much as $100. A more expensive option is a so-called dynamic lighting system, which promises to re-create “the full range of natural daylight in an interior space” for hundreds to thousands of dollars depending on the size of one's home or office.

The most affordable countermeasures are computer programs such as f.lux. This past March, Apple introduced a function called Night Shift for the iPhone and iPad, which mimics f.lux in shifting the screen's emitted light “to the warm end of the spectrum” around sunset. So far no researchers have tested f.lux or Apple's Night Shift in a controlled study, but Figueiro says she is planning to conduct such experiments, and Michael Herf says he is collaborating with university scientists to examine the effects of f.lux in everyday environments outside the laboratory. “F.lux in my view is still a hypothesis,” Herf adds. “We think it probably helps a lot of night owls, but we still need to support the anecdotes with data.”

Researchers emphasize, however, that eliminating blue light is not a fail-safe solution. Even dim, orange screens make it tantalizingly easy to stay awake and read, watch movies or play games at night, keeping your brain alert when it should be winding down. “It's as if you're completely in the dark, but you drink coffee,” Figueiro explains. “It's still going to have an effect.”

Ultimately the surest solution is electronic abstinence: shutting off all screens and bright lights for at least a few hours before bedtime. The inescapable fact is that humans evolved to rise and sleep with the sun. “Before we had all this technology, before electricity and artificial lighting, we would be awake in daylight, have a little bit of fire in the evening, and then sleep,” says Debra Skene, a chronobiologist at the University of Surrey in England. Artificial light has been enormously beneficial over the centuries. But there are times, especially at the end of the day, when it can be too much of a good thing.