Opiate drugs and medications — such as morphine, heroin, and codeine — can be detected in a urine test up to 3 days after use.

Urine tests can detect opiates in your system for up to 3 days, depending on which drug or medication you used. The period of detection for heroin may be as short as one day, while codeine and morphine could be detected via urine for up to 3 days after your last dose.

The words “opiate” and “opioid” are used interchangeably, but they’re not the same thing. Opiate drugs are derived from a naturally occurring substance called opium, while opioids are a broader class of drugs that include opiates and similar synthetic drugs.

Opiates include codeine, morphine, and heroin. Synthetic and semi-synthetic opioids include fentanyl, oxycodone, methadone, and tramadol.

Opioid medications are very effective at managing pain. Because they can produce a temporary feeling of euphoria, opioid medications are highly addictive and commonly misused.

You may be tested for opioids if you’re undergoing a treatment program or if you’re employed at a company with a drug-free policy. If a doctor prescribes opioids to you, they may request testing to ensure you’re not already using opioids.

Depending on the testing method, opiate medications can be detectable for between 1 day and 90 days.


Urine tests can detect traces of opiate medications for 1–3 days after use, according to the Food and Drug Administration. The detection period depends on exactly which medication or drug you used.

Here are the most common opiates and the detection period for urine testing:

  • codeine: up to 3 days
  • heroin: as little as 1 day, up to 3 days
  • morphine (Avinza, Duramorph): up to 3 days

The detection window for synthetic and semi-synthetic opioids can be longer.

Here are the most common synthetic and semi-synthetic opioids and the detection period for urine testing:

  • buprenorphine (Buprenex, Suboxone): up to 14 days
  • fentanyl: up to 3 days
  • hydrocodone (Lorcet, Vicodin): up to 3 days
  • hydromorphone (Dilaudid, Exalgo): up to 3 days
  • meperidine (Demerol, Mepergan): up to 4 days
  • methadone (Dolophine, Methadose): up to 14 days
  • oxycodone (Oxycontin, Percocet): up to 2 days
  • oxymorphone (Numorphan, Opana): up to 3 days
  • tramadol (Ultram): up to 4 days


Heroin can be detected in saliva for up to 5 hours after use. Morphine and codeine, on the other hand, can be detected up to 4 days after use.


Compared to urine testing, blood testing typically has a shorter detection period.

Blood tests can detect opiate use until:

  • codeine: up to 1 day
  • heroin: up to 6 hours
  • morphine: up to 3 days


Hair follicle tests can detect traces of opioids for up to 90 days after you use them.

Hair follicle tests have a very long detection period. Chemicals travel to the hair follicles via the capillaries in the scalp, and a hair segment taken close to the scalp can be used to detect drugs for up to 90 days after you use them.

Different opiates take different amounts of time to break down.

According to research, heroin and morphine are relatively quick to metabolize. One 2019 historical review of research points to evidence that heroin has a half-life of as little as 2 to 3 minutes, while morphine has a half-life of 2 to 3 hours. Similarly, the half-life of codeine is about 3 hours.

A drug’s half-life is the time it takes for half of the drug to leave your body. Most sources estimate that it takes around five half-lives for a drug to totally exit your body.

This means that it can take as little as 10 minutes for heroin to leave your system, and 10 to 15 hours for morphine and codeine to leave your system. This could explain why opiate withdrawal symptoms can occur so soon after use.

Bear in mind, though, that even if the effects have worn off, traces of the drugs can be detected in your urine, saliva, blood, and hair for longer.

A number of factors can affect how quickly your body metabolizes opiate medications, according to a research review published in 2009.

These factors include:

  • Age: Older people often take longer to metabolize opiate drugs.
  • Combination of other drugs: Your body eliminates opioids through a pathway called cytochrome P450 3A (CYP3A). Certain drugs can affect this pathway, making it more difficult for your body to metabolize and eliminate opioids.
  • Genetics: The 2009 research review suggests that genetic factors may affect how quickly you metabolize opioids.
  • Kidney and liver function: Your kidneys and liver play a role in processing and eliminating drugs. People with kidney or liver conditions may metabolize opioids more slowly.
  • Length of use: When you take drugs or medications regularly, they may be stored in your fatty tissues. This means your body will take longer to eliminate it.

It’s possible that other factors may play a role in how people metabolize opiate medications. Future research will explore what those factors are and how they affect the process.

No. The factors that affect how you metabolize opiates are out of your control.

There are no proven ways to rid your system of opiates. If someone is experiencing an opioid overdose, naloxone (Narcan) can help. Naloxone does not make the body metabolize opioids faster; it just reverses the overdose, potentially saving their life.

If you think you or someone you know has overdosed on opioids, contact emergency services immediately.

Administering Narcan can stop a potentially fatal overdose, but it’s not a substitute for medical services — it’s still essential to get to the emergency room as soon as possible.

A urine test can detect opiates — such as morphine, heroin, and codeine — for up to 3 days after use. Saliva and hair follicle tests may detect opiate use after a longer period.

If you’re experiencing intense side effects after using opioids — or if you or someone you know might have overdosed on heroin — immediately seek emergency medical help.

Sian Ferguson is a freelance health and cannabis writer based in Cape Town, South Africa. She’s passionate about empowering readers to take care of their mental and physical health through science-based, empathetically delivered information.