How Are Stomach Ulcers Diagnosed: Endoscopy and More

Stomach ulcers are diagnosed through a combination of tests that identify the ulcer itself and determine its cause, most commonly an infection with the bacterium H. pylori. The two main diagnostic paths are endoscopy, which lets a doctor directly see the ulcer, and noninvasive tests like breath and stool tests that detect the underlying infection. Which tests you’ll need depends on your symptoms, age, and risk factors.

Upper Endoscopy: The Most Definitive Test

An upper endoscopy (sometimes called an EGD) is the gold standard for diagnosing stomach ulcers. A doctor passes a thin, flexible tube with a camera down your throat and into your stomach and the first part of your small intestine. The camera gives a real-time view of the stomach lining, making it possible to spot ulcers, measure their size, note their location, and assess how severe they are.

During the same procedure, the doctor will almost always take biopsies, small tissue samples snipped from the ulcer and surrounding area. These serve two purposes: testing for H. pylori infection and checking for cancer. That second point matters more than most people realize. In published data, the rate of malignancy among endoscopically diagnosed gastric ulcers ranges from roughly 2.4% to 21% depending on the population studied, with one large cohort finding 4.7% were cancerous. Because of this, current guidelines recommend that all gastric ulcers be followed up with repeat endoscopy and biopsy to confirm healing and rule out malignancy.

Preparation is straightforward. You’ll need to stop eating solid food for eight hours and stop drinking liquids for four hours beforehand so your stomach is empty. If you take blood thinners, your doctor will likely ask you to pause them in the days before the procedure to reduce bleeding risk. You’ll also want to share a full list of medications and supplements you’re taking. During the procedure itself, you’re typically sedated, so you won’t feel discomfort, but you’ll need someone to drive you home afterward.

Breath Test for H. Pylori

If your doctor suspects a stomach ulcer but wants to start with a less invasive approach, the urea breath test is the most accurate noninvasive option for detecting H. pylori. You swallow a small capsule, liquid, or pudding containing a specially labeled form of urea. If H. pylori bacteria are present in your stomach, they break down the urea and release carbon dioxide containing a detectable carbon marker. After a few minutes, you breathe into a container, and the exhaled air is analyzed for that marker.

The test is highly reliable. Studies show sensitivity around 92% to 94%, meaning it correctly identifies the infection in the vast majority of people who have it. It’s quick, painless, and can often be done right in a doctor’s office.

There’s one important catch: certain medications can produce a false negative, making the test look clean even when you’re infected. You may need to stop taking proton pump inhibitors (common acid-reducing drugs like omeprazole), antibiotics, and bismuth-based products like Pepto-Bismol a few weeks before the test. Your doctor will give you specific timing instructions.

Stool Antigen Test

A stool antigen test is another noninvasive way to check for an active H. pylori infection. Your doctor gives you a collection container with instructions to take home. You provide a sample and return it for lab analysis, where it’s checked for proteins from the H. pylori bacterium.

This test is especially useful in two situations: initial diagnosis when endoscopy isn’t needed yet, and confirming that a previous H. pylori infection has been successfully treated. Like the breath test, it detects active infection rather than past exposure. The same medication restrictions apply. You’ll need to stop PPIs, antibiotics, and bismuth products ahead of the test to avoid inaccurate results.

Why Blood Tests Are Rarely Used Anymore

Older diagnostic approaches relied on blood tests that look for antibodies to H. pylori. These have largely fallen out of favor for a simple reason: they can’t distinguish between a current infection and one you cleared years ago. Antibodies can remain in your blood long after the bacteria are gone, so the test stays positive even after successful treatment. This makes it useless for confirming whether treatment worked, and unreliable for initial diagnosis in many cases. Breath and stool tests have replaced it in most clinical settings.

Upper GI Series (Barium Swallow)

In some cases, doctors order an upper GI series instead of or before endoscopy. You swallow a chalky barium liquid that coats your digestive tract, then X-rays are taken as the barium moves through your esophagus, stomach, and upper small intestine. The barium makes ulcers and other abnormalities visible on the images.

This test is noninvasive and extremely safe, but it has real limitations. It struggles to detect mild irritation of the stomach lining and can miss ulcers smaller than about a quarter inch in diameter. Critically, no biopsies can be taken during the procedure, so if anything suspicious shows up, you’ll still need an endoscopy. For these reasons, a barium swallow is more of a screening step than a final answer. It’s sometimes used when endoscopy isn’t readily available or when a patient’s symptoms are less severe.

What Determines Which Tests You Get

Not everyone with suspected stomach ulcers goes straight to endoscopy. If you’re younger (generally under 60), have no alarming symptoms like unexplained weight loss, difficulty swallowing, or signs of bleeding, your doctor may start with a noninvasive H. pylori test. A positive result combined with your symptoms can be enough to begin treatment without looking directly at the ulcer.

Endoscopy becomes more important when symptoms are severe, when there are warning signs of complications, when you’re older and cancer risk increases, or when initial treatment hasn’t resolved the problem. It’s also the only way to directly visualize the ulcer and take tissue samples. If your doctor finds an ulcer during endoscopy, a follow-up scope is typically recommended weeks later to confirm the ulcer is healing, especially since a small but meaningful percentage of gastric ulcers turn out to be malignant.

Regardless of which path your diagnosis takes, the goal is the same: confirm the ulcer exists, identify whether H. pylori or another cause (like long-term use of anti-inflammatory painkillers) is behind it, and rule out anything more serious. Most people get their noninvasive test results within a few days, while biopsy results from endoscopy can take slightly longer as a pathologist examines the tissue under a microscope.