The short answer
Some vaccines help prevent cancer by stopping infections that can lead to it. The HPV vaccine prevents infections that cause cervical and several other cancers, and the hepatitis B vaccine prevents an infection that can cause liver cancer. These preventive vaccines are different from treatment vaccines, which are used in people who already have cancer.
Some vaccines prevent cancer by stopping infections that can lead to it.
The HPV vaccine prevents infections that cause cervical and several other cancers.
The hepatitis B vaccine prevents an infection that can cause liver cancer.
Preventive (prophylactic) vaccines are given before infection to healthy people.
Choose how you want to read this
The whole article, with every detail and caution.
The simple version
Most people think of vaccines as protection against illnesses like the flu. But a few vaccines also help prevent cancer.
They do this in a clever way. Some viruses can cause cancer over time. Vaccines that stop those infections can also stop the cancers they might have led to.
The HPV and hepatitis B vaccines are the two main examples of cancer-preventing vaccines.
How a vaccine can prevent cancer
Certain viruses are known to cause cancer. When a vaccine prevents one of these infections, it can prevent the cancer that infection might have caused years later.
This is an indirect but powerful approach. The vaccine does not attack cancer cells. Instead, it trains your immune system to stop the virus before it can take hold and cause harm.
Because these viruses often lead to cancer only after many years of infection, preventing the infection early can lower cancer risk far into the future.
Preventive vaccines versus treatment vaccines
It helps to know that "cancer vaccine" can mean two very different things:
- Preventive (prophylactic) vaccines are given to healthy people before infection. Their goal is to stop a cancer-causing virus. The HPV and hepatitis B vaccines are this kind. This article is about them.
- Treatment vaccines are given to people who already have cancer. Their goal is to help the immune system fight the existing cancer. These are part of cancer treatment, not prevention.
Keeping these two apart avoids a lot of confusion.
The HPV vaccine
HPV, or human papillomavirus, is a common virus. Certain types can cause cancer. The HPV vaccine protects against the types most likely to lead to cancer.
By preventing these infections, the vaccine helps prevent:
- Cervical cancer
- Some anal, throat, penile, vulvar, and vaginal cancers
It is recommended for preteens. In some cases it can be given up to age 45 after a conversation with a doctor. The section on timing below explains why age matters.
The hepatitis B vaccine
Hepatitis B is a virus that infects the liver. A long-term infection can, over many years, lead to liver cancer.
The hepatitis B vaccine prevents this infection. By doing so, it lowers the risk of liver cancer down the road. NCI notes that infants in the United States and most other countries are routinely vaccinated against it. The CDC recommends it for all infants, for children and adolescents younger than 19 who have not been vaccinated, for adults 19 to 59, and for adults 60 and older with risk factors for hepatitis B.
Vaccines and screening work together
Cancer-preventing vaccines are powerful, but they are not the whole story. They work best alongside screening.
For example, the HPV vaccine does not protect against every type of HPV that can cause cancer. So people should still follow cervical cancer screening guidelines even if they had the vaccine. Vaccines lower risk, and screening catches problems early. Together, they offer stronger protection than either alone.
Are they safe?
The HPV and hepatitis B vaccines have been studied widely. NCI reports the HPV vaccine has been monitored for over 20 years, and the most common problems are brief soreness and other local symptoms at the injection site.
If you have questions about whether you or your child is due for these vaccines, or whether they make sense at your age, your care team is the best guide. They can look at your history and help you decide.
Why timing matters
For preventive vaccines, timing makes a real difference. They work best when given before a person is exposed to the virus.
That is why the HPV vaccine is recommended for preteens, well before most people could be exposed. It can still be given to older teens and young adults, but the benefit is greatest earlier. Similarly, the hepatitis B vaccine is often given in childhood so protection is in place early.
This does not mean it is too late for everyone else. Depending on your situation, a vaccine may still be helpful. A conversation with your doctor can sort out what fits your age and history.
The bigger picture
Cancer-preventing vaccines are a good example of how science can stop some cancers before they start. By preventing the infections that cause them, these vaccines protect against several cancers at once, often for many years.
Getting recommended vaccines, staying up to date on screening, not smoking, and living healthy habits all work together to lower cancer risk. No single step covers everything, but each one adds protection. If you are unsure whether you or your family members are protected against HPV and hepatitis B, your care team can check your records and fill any gaps.
Sources

Common questions
How can a vaccine prevent cancer?
Some viruses can cause cancer. Vaccines that prevent those infections can, in turn, help prevent the cancers they lead to. The HPV and hepatitis B vaccines work this way. They do not target cancer cells directly; they stop the infection that could cause cancer later.
Which cancers can vaccines help prevent?
The HPV vaccine helps prevent cervical cancer and several other cancers linked to HPV, such as some anal, throat, penile, vulvar, and vaginal cancers. The hepatitis B vaccine helps prevent liver cancer by preventing long-term hepatitis B infection.
What is the difference between preventive and treatment vaccines?
Preventive vaccines are given to healthy people before infection to stop a virus that could cause cancer. Treatment vaccines are given to people who already have cancer, to help the immune system fight it. This article is about the preventive kind.
Who should get the HPV vaccine?
The HPV vaccine is recommended for preteens, and it can be given through the mid-20s and, in some cases, up to age 45 after talking with a doctor. It works best when given before someone is exposed to the virus. Your care team can advise on timing.
Do these vaccines replace cancer screening?
No. For example, people should still follow cervical cancer screening guidelines even if they had the HPV vaccine, because the vaccine does not protect against every type. Vaccines and screening work together to lower risk.
Are these vaccines safe?
The HPV and hepatitis B vaccines have been studied widely. NCI reports the HPV vaccine has been monitored for over 20 years, and the most common problems are brief soreness and other local symptoms at the injection site. Your care team can answer specific questions about either vaccine.
Questions to ask your doctor
Being prepared helps you get the most out of your appointments. Save or print these questions.
Tap a question to save it to your list (kept on this device).
Talk with a trained specialist or navigator
Cancer Explained provides educational guidance, but does not replace trained specialists, social workers, or your medical team.
Talk to a trained cancer information specialist
Free, confidential assistance from NCI Cancer Information Service via phone, chat, or email.
Contact your oncology team
Locate after-hours contact numbers, portal messages, or urgent triage phone lines.
Find a patient navigator
Get one-on-one help with appointments, logistics, translation, and care coordination.
Find a genetic counselor
Discuss inherited mutation risk, family history, and genetic testing options.
Find an oncology social worker
Access emotional counseling, family support groups, and mental health resources.
Find a financial navigator
Locate copay assistance foundations, grant programs, and lodging/travel support.
Find a clinical-trial specialist
Search matching studies and speak with NCI trial information specialists.
Get urgent help
Fever of 100.4°F (38°C) or higher during chemo, severe pain, or trouble breathing: call your cancer care team right away, day or night. Call 911 for an emergency.
Plain-language explanation of the published sources cited on this page. AI-assisted, source-checked, not clinician-reviewed.
Last updated: 2026-10-16Next planned review: 2027-07-04
Review details and limits
Cancer Explained does not originate medical claims. Every page restates guidance already published by the National Cancer Institute, the CDC, the USPSTF and the FDA, in plain language, with the source cited so you can check the original yourself. AI does the translating and organizing; automated checks test claims, citations, clarity and safety before anything publishes, and this is translation and navigation, not clinical judgment. Nothing here is personal medical advice, and no page can account for your particular situation.
Editorial status — Source checked. This page was written with AI assistance and then compared with the sources listed on it, looking for statements those sources do not back up. That check is not a sentence-by-sentence record and can miss errors. It is not a medical review, and it does not confirm the page is complete or right for your situation.
General education — varies by person. Answers genuinely differ between people. This page explains what commonly varies and points you to your care team for your situation.
Human medical review: not completed. Pages here are not signed off by a clinician before they publish. That is not an oversight we are quietly working around: we restate published guidance and cite it, so the authority belongs to the source rather than to us, and every page names where its claims come from — you can verify us instead of trusting us. Where a volunteer clinician has reviewed a page, their name and credentials appear on it; where no name appears, no clinician has checked it. We are glad to have reviewers and are recruiting them, and we do not hold pages back waiting for one. Use this site to understand your situation and to ask better questions of the people treating you.
Words to know
Tap any term to see what it means.
Knowledge check
0 of 4 answered
This self-assessment checks understanding of educational content only. It is not medical advice.
How this page was created
Cancer Explained does not originate medical claims. Every page restates guidance already published by the National Cancer Institute, the CDC, the USPSTF and the FDA, in plain language, with the source cited so you can check the original yourself. AI does the translating and organizing; automated checks test claims, citations, clarity and safety before anything publishes, and this is translation and navigation, not clinical judgment. Nothing here is personal medical advice, and no page can account for your particular situation.
Editorial status: Source checked — This page was written with AI assistance and then compared with the sources listed on it, looking for statements those sources do not back up. That check is not a sentence-by-sentence record and can miss errors. It is not a medical review, and it does not confirm the page is complete or right for your situation.
Human medical review: not completed. Pages here are not signed off by a clinician before they publish. That is not an oversight we are quietly working around: we restate published guidance and cite it, so the authority belongs to the source rather than to us, and every page names where its claims come from — you can verify us instead of trusting us. Where a volunteer clinician has reviewed a page, their name and credentials appear on it; where no name appears, no clinician has checked it. We are glad to have reviewers and are recruiting them, and we do not hold pages back waiting for one. Use this site to understand your situation and to ask better questions of the people treating you.
Read more about our editorial process, our use of AI, and our corrections policy.
Spotted a problem? Report an error — a factual mistake, broken or outdated source, confusing wording, or anything that seems unsafe. Please do not include names, medical record numbers, dates of birth, addresses, or other identifying medical information in your report.
After using this page, do you understand what to do next?
Anonymous — we only record the answer, never who gave it.
