A secret from the Great Barrier Reef could lead to a pill that prevents sunburn within five years, scientists say.

British researchers who analysed coral samples from Queensland's Great Barrier Reef have uncovered the unique way coral shields itself against harmful ultraviolet (UV) rays.

They believe the discovery could pave the way to a sunscreen revolution with a tablet that protects both skin and eyes.

The scientists are close to producing a synthetic anti-sun compound based on those found in coral.

If the research progresses as hoped, the first sunscreen pill could become a reality in five years.