Vitamin D has something special going for it.

You get most of the vitamins your body needs from foods you eat. And you can get a good helping of vitamin D from certain foods. But it’s not the most common way to get it.

“More than 90% of our vitamin D comes from sunlight,” says family medicine physician Charles Garven, MD. (Hence its nickname, the sunshine vitamin.)

But this isn’t a “more is better” situation.

Yes, you need vitamin D. And, yes, some time spent outside enjoying a beautiful day is good for you. But it doesn’t take hours of baking on the beach to get your vitamin D. And excessive time in the sun can bring on its own problems.

Where’s the line? Dr. Garven shares advice.

How the sun creates vitamin D

Your skin makes vitamin D when it’s exposed to sunlight. From there, your body processes and uses it.

“When sunlight hits your skin, it triggers a chemical reaction that converts inactive forms of vitamin D into the active form your body can use — namely, vitamin D3,” Dr. Garven explains.

This process depends specifically on ultraviolet B (UVB) rays. The trouble is, UV (ultraviolet) rays are also responsible for sunburns and other skin damage. More on that in a bit.

Benefits of vitamin D from the sun

Vitamin D is an essential nutrient. It’s an important player in boosting your immune system, supporting muscle function and encouraging heart health.

But it’s perhaps best known for its power to boost your bone health. That’s because vitamin D helps your body absorb and use calcium, which is essential for strong bones.

“Over time, low vitamin D levels can contribute to weaker bones and a higher risk of fractures,” Dr. Garven reports. “So, we focus a lot on vitamin D to improve bone density and prevent osteoporosis.”

Vitamin D also has a reputation for being a mood enhancer. But there may be more to that than meets the eye.

It’s true that the vitamin itself may help regulate your emotional well-being. But Dr. Garven points out that time spent outdoors also encourages other healthy habits, like being physically active, socializing and reflecting in nature — all of which can have mood-boosting effects, too.

Risks of excessive sun exposure

Here’s where things get tricky. Sunlight is essential for vitamin D production, but too much sun exposure is a real risk.

Too much time spent in the sun without proper protection increases your risk of:

  • Skin damage
  • Premature skin aging
  • Sunburns
  • Skin cancer, including life-threatening melanoma

The risks of too much sun are why Dr. Garven emphasizes moderation — and absolutely avoiding tanning beds.

“Tanning bed lights use a higher concentration of UVA and much lower UVB,” he warns. “You get no vitamin D benefit from them — only risk.”

Vitamin D and sun safety

The sweet spot is finding the balance between getting enough sunlight for vitamin D production while also protecting your skin from sun damage.

Dr. Garven recommends following these tips.

Use sunscreen

Some people worry that using sunscreen cancels out vitamin D production — but that’s not the case.

“Sunscreen doesn’t block vitamin D conversion,” Dr. Garven confirms. “It blocks the sun’s damaging effects.”

Sunscreen lowers how much UV radiation reaches your skin. That helps protect you from the risks of sun damage. But it doesn’t block UV light completely. So, your body can still make vitamin D, especially if you’re outdoors for more than a few minutes.

Wearing sunscreen means you benefit from the best of both worlds: You’ll still get your vitamin D, but with less risk.

If you plan to be outside for more than a short period of time, use a broad-spectrum sunscreen with SPF 30 or higher, and reapply it as directed. For best protection, use sunscreen every day.

Keep exposure short

When it comes to vitamin D from the sun, more time outside isn’t necessarily better.

For most people, just 10 to 30 minutes of direct sunlight is enough to support vitamin D production. After that point, Dr. Garven says, “The risks start to outweigh any additional benefits.”

Longer exposure doesn’t mean your body keeps making more vitamin D indefinitely. Instead, what you’re accumulating is damage to your skin, especially if you’re exposed day after day without protection.

That’s why brief, regular exposure — rather than prolonged sunbathing — is the safer approach.

Be strategic

Spending time outdoors is important for your physical and mental well-being. And Dr. Garven encourages you not to lose sight of that.

“Getting outside, being active, doing things that aren’t sitting and scrolling — those things have benefits beyond vitamin D alone,” he encourages.

But it pays to be thoughtful about how and when you get your fill of sunshine. On high‑UV days, in particular, consider:

The goal isn’t to avoid the sun. It’s to work with it — getting what your body needs while protecting your skin for the long term.

Alternatives to getting vitamin D from the sun

Sunlight is the primary source of vitamin D, but it’s not the only one.

You can get vitamin D from some foods, too. Good sources include cod liver oil, rainbow trout and sockeye salmon. Several common foods are also fortified with vitamin D, including:

  • Cereal
  • Milk
  • Orange juice
  • Yogurt

Supplements may also be an option.

“For the majority of folks, vitamin D supplements are generally safe,” Dr. Garven says. “But they’re not right for everyone, especially if you have kidney disease. It’s always best to talk with a healthcare provider before starting any kind of supplement.”

What’s more, taking supplements shouldn’t be a replacement for enjoying safe fun in the sun.

“Being outside and staying active has benefits beyond vitamin D,” he reiterates.

The key is balance — get some sun, protect your skin and talk to a healthcare provider if you’re concerned about your vitamin D levels.

This article was written by Cleveland Clinic Health Essentials (editorial@ccf.org) from Cleveland Clinic and was legally licensed through the DiveMarketplace by Industry Dive. Please direct all licensing questions to legal@industrydive.com.