~DEVELOPER

NDC Codes Explained: How Drug Identification Works in the US

What National Drug Codes (NDC) are, their 3-segment structure, and how to use the NDC Directory API for drug lookups and pharmacy data integration.

by MyfitByte(11 min read)

NDC Codes Explained: How Drug Identification Works in the US

What an NDC code is

The National Drug Code (NDC) is a unique 10-11 digit identifier assigned to every commercial drug product in the United States. It is the universal product identifier for drugs, used by pharmacies, hospitals, insurers, and PBMs to track medications from manufacturer to patient.

Every bottle, vial, blister pack, and tube of medication sold in the US has an NDC printed on its label.

The three-segment structure

An NDC breaks down into three segments:

XXXXX-YYYY-ZZ
Labeler - Product - Package
Segment Length Identifies
Labeler 4-5 digits Company that manufactures or distributes
Product 3-4 digits Specific drug, strength, dosage form
Package 1-2 digits Package size and type

Example: 0078-0951-05

  • 0078 = Novartis (labeler)
  • 0951 = Diovan 160mg tablet (product)
  • 05 = Bottle of 90 (package)

The 10-digit vs 11-digit problem

NDCs are technically 10 digits, but they are commonly stored and transmitted as 11 digits with leading zeros added to one segment. This creates a notorious interoperability headache.

The three possible 10-digit formats:

  • 4-4-2 (e.g., 0078-0951-05)
  • 5-3-2 (e.g., 12345-678-90)
  • 5-4-1 (e.g., 12345-6789-0)

To convert to 11-digit format, add a leading zero to whichever segment is shorter than its maximum:

  • 4-4-2 becomes 00078-0951-05 (5-4-2)
  • 5-3-2 becomes 12345-0678-90 (5-4-2)
  • 5-4-1 becomes 12345-6789-00 (5-4-2)

Insurance claims, pharmacy systems, and hospital EHRs do not always agree on which format to use. This is one of the most common sources of drug-matching failures in healthcare IT.

Looking up NDCs programmatically

The FDA NDC Directory API provides structured access:

# Search by brand name
curl "https://api.fda.gov/drug/ndc.json?search=brand_name:\"Ozempic\"&limit=10"

# Search by generic name
curl "https://api.fda.gov/drug/ndc.json?search=generic_name:\"semaglutide\"&limit=10"

# Search by labeler (company)
curl "https://api.fda.gov/drug/ndc.json?search=labeler_name:\"Novo+Nordisk\"&limit=50"

The response includes the full NDC, drug name, strength, dosage form, route of administration, DEA schedule, marketing status, and package descriptions.

Why one drug has dozens of NDCs

Semaglutide (Ozempic) alone has 20+ distinct NDCs. Each combination of:

  • Strength (0.25mg, 0.5mg, 1mg, 2mg)
  • Package size (1 pen, 2 pens, sample pack)
  • Labeler/distributor

gets its own NDC. A generic drug manufactured by five companies with three strengths each in two package sizes means 30 NDCs for what a patient considers "the same medication."

This is why drug identity resolution (mapping from brand name to all relevant NDCs) is a significant engineering challenge.

NDC in claims data

Insurance claims (837P and NCPDP transactions) use NDC as the primary drug identifier. When analyzing claims data:

  • The NDC on a claim tells you exactly which product was dispensed
  • You can map NDC to therapeutic class, manufacturer, and generic equivalent
  • Price analysis requires grouping by NDC (different package sizes have different costs)
  • Generic substitution analysis compares NDCs with the same product code but different labelers

Where NDC falls short

NDC does not cover:

  • Compounded medications (custom pharmacy preparations have no NDC)
  • Non-commercial drugs (clinical trial medications)
  • Combination medical devices (drug-device combos may use device identifiers)
  • Foreign drugs (no NDC for products not marketed in the US)

For these gaps, other coding systems like RxNorm (NLM) and ATC (WHO) provide alternative mapping.

NDC vs RxNorm vs ATC

System Maintained by Purpose Granularity
NDC FDA Commercial product identification Package level
RxNorm NLM (NIH) Clinical concept mapping Ingredient + strength + form
ATC WHO Therapeutic classification Drug class level

RxNorm is the bridge between them. It maps NDCs to clinical drug concepts, allowing you to group all "metformin 500mg tablets" regardless of manufacturer or package size.

Where to find the NDC number

Patients and pharmacists encounter NDC numbers in different places:

On the prescription bottle/box: The NDC is printed on every commercially sold medication. Look for "NDC" followed by a 10 or 11-digit number, usually near the barcode on the outer packaging. On prescription bottles from the pharmacy, it appears on the label applied by the dispensing pharmacist.

On insurance claims: The NDC is field 407-D7 on NCPDP pharmacy claims. Every time a pharmacist fills a prescription and bills insurance, the NDC identifies exactly which product was dispensed.

On an Explanation of Benefits (EOB): Some insurers print the NDC on patient statements under the medication section.

On the FDA NDC Directory website: Search any drug at dailymed.nlm.nih.gov or through the openFDA API.

NDC barcodes: two encoding standards

The barcode on a drug package encodes the NDC in one of two formats:

Barcode Type Standard Where Used
Linear (UPC-A style) Based on 10-digit NDC Retail pharmacy scanning
2D DataMatrix Encodes full NDC + lot + expiration Hospital unit-dose packaging

Retail pharmacies scan the linear barcode at point of sale. Hospital automated dispensing cabinets (Pyxis, Omnicell) use the 2D DataMatrix, which contains more information for inventory management.

The barcode does not always match the printed NDC format exactly. Scanning software performs the 10-to-11-digit conversion internally.

NDC vs. UPC: what's the difference?

Both are product identifiers printed on packaging, but they serve different systems:

NDC UPC
Governed by FDA GS1 (formerly Uniform Code Council)
Applies to Prescription and OTC drugs All retail products
Structure 3 segments (labeler-product-package) Company prefix + item reference
Length 10-11 digits 12 digits
Required by Federal law (Drug Listing Act of 1972) Voluntary retail standard
Contains Drug identity, strength, form, package Product identity only

OTC drugs have both an NDC and a UPC. The UPC is what the grocery store scans. The NDC is what the pharmacy system uses. They are different numbers that point to the same product.

NDC vs. GPI vs. RxNorm: choosing the right code system

Different systems serve different purposes. Picking the wrong one causes mapping headaches downstream.

System Best For Granularity Who Maintains It
NDC Billing, dispensing, inventory Package level (specific bottle/box) FDA
GPI (Generic Product Identifier) Formulary management, therapeutic classification Drug group level Medi-Span (Wolters Kluwer)
RxNorm Clinical interoperability, EHR systems Clinical concept (ingredient + strength + form) NLM (NIH)
ATC Research, international comparison Therapeutic class WHO
HCPCS/J-codes Physician-administered drugs (Part B) Procedure level CMS

If you're building a pharmacy system: use NDC as your primary key. If you're building a clinical decision tool: use RxNorm. If you're building formulary analytics: use GPI. If you're joining claims to clinical data: you need the NDC-to-RxNorm crosswalk from NLM's RxNorm API.

Do compounded medications have NDC numbers?

No. Compounded medications (custom preparations mixed by a pharmacy for individual patients) do not have NDC numbers. An NDC is assigned by the manufacturer when they register the product with the FDA. Compounders are not manufacturers in this regulatory sense.

This creates a billing problem. Pharmacy claims systems expect an NDC in field 407-D7. For compounded prescriptions, pharmacies use one of these workarounds:

  • A "compound" indicator flag on the claim
  • Individual NDCs for each ingredient used in the compound
  • A pharmacy-specific internal code

State boards of pharmacy handle compounding oversight, not the FDA (unless the pharmacy qualifies as a 503B outsourcing facility). This regulatory gap is why the GLP-1 compounding crackdown in 2025-2026 became complicated — compounded semaglutide had no NDC, making it harder to track through normal pharmacy data systems.

How to convert between 10-digit and 11-digit NDC formats

The 10-to-11-digit conversion problem is the most common NDC headache in healthcare IT. Here's the algorithm:

Step 1: Determine which segment is "short" (below maximum length):

  • Labeler max = 5 digits
  • Product max = 4 digits
  • Package max = 2 digits

Step 2: Pad the short segment with a leading zero.

def ndc_10_to_11(ndc_10):
    """Convert 10-digit NDC (with dashes) to 11-digit format."""
    parts = ndc_10.split('-')
    if len(parts[0]) == 4:    # 4-4-2 format
        return '0' + parts[0] + parts[1] + parts[2]
    elif len(parts[1]) == 3:  # 5-3-2 format
        return parts[0] + '0' + parts[1] + parts[2]
    elif len(parts[2]) == 1:  # 5-4-1 format
        return parts[0] + parts[1] + '0' + parts[2]

The catch: If you receive an NDC without dashes (just 10 digits), you cannot determine which format it uses. You'd need a lookup against the FDA NDC Directory to resolve the ambiguity. This is why storing NDCs without their original dash positions is a data quality anti-pattern.

NDC in medical billing

NDC plays different roles in different claim types:

Pharmacy claims (NCPDP format): NDC is the primary drug identifier. Required. Without it, the claim rejects.

Medical claims (837P/837I, CMS-1500, UB-04): NDC is sometimes required for physician-administered drugs (J-code billing). CMS and some states mandate NDC reporting on medical claims for drugs billed under HCPCS codes.

Medicare Part B drugs: When a physician administers a drug in-office (infusions, injections), the claim uses a HCPCS J-code for billing and an NDC for identification. The NDC tells CMS exactly which product was administered.

Rebate processing: Manufacturers pay rebates to Medicaid and commercial payers based on NDC-level utilization. The NDC determines the rebate amount because each NDC has a specific price (Average Manufacturer Price, Wholesale Acquisition Cost).

The NDC Directory bulk download

For developers building drug databases, the FDA NDC Directory is available as a bulk download:

# Download the full NDC Directory (tab-delimited text)
curl -O "https://www.accessdata.fda.gov/cder/ndctext.zip"
unzip ndctext.zip
# Contains: product.txt (drug info), package.txt (package sizes)

The file contains two tables:

  • product.txt: One row per drug product (brand name, generic name, dosage form, route, DEA schedule, labeler, marketing status)
  • package.txt: One row per package configuration (NDC, package description, sample package flag)

Join on PRODUCTID. The product table tells you what the drug is. The package table tells you how it's sold.

Updated daily by the FDA. About 25 MB uncompressed.

FAQ

How many active NDCs exist? The FDA NDC Directory contains roughly 300,000 active listings. Including discontinued products, the total exceeds 500,000.

Do NDCs expire or get reassigned? NDCs are supposed to be unique forever, but the FDA allows reassignment after 5 years of non-marketing. This creates historical matching problems in claims analytics — the same NDC can point to two different drugs depending on the date.

Is the NDC Directory updated in real time? The FDA updates the directory daily. New products appear as manufacturers register them. The openFDA API mirrors these updates weekly.

What is the best way to store NDC in a database? Store as 11-digit (5-4-2 format) with dashes stripped, in a CHAR(11) column. Convert on input. Keep the original 10-digit format with dashes in a separate column for display and audit purposes.

Can I map NDC to drug price? NDC is the key used in CMS pricing files. NADAC (National Average Drug Acquisition Cost) and ASP (Average Sales Price) both use NDC as their primary identifier.

Where is the NDC number on a prescription bottle? On the pharmacy label applied to your bottle. Look for "NDC:" followed by a number in the format XXXXX-XXXX-XX. On manufacturer packaging, it appears near the barcode on the outer box or on the bottle's back label.

Do OTC drugs have NDC numbers? Yes. Every commercially marketed drug product in the US (prescription and OTC) is assigned an NDC upon FDA registration. Tylenol, Advil, and store-brand generics all have NDCs.

What is a labeler code? The first 4 or 5 digits of an NDC. It identifies the company that manufactures, repacks, or distributes the drug. The FDA assigns labeler codes when a company registers with the Drug Listing system. One company can have multiple labeler codes (for subsidiaries, repackagers, etc.).

How many digits is an NDC? Technically 10 digits in three segments (4-4-2, 5-3-2, or 5-4-1 format). The healthcare industry commonly uses an 11-digit version (5-4-2) with a leading zero added to the short segment. Both are correct but represent different conventions.

Is the NDC the same as a drug label? No. The NDC is a numeric identifier. The drug label (prescribing information) is the full text document describing the drug's indications, dosing, warnings, and clinical trial data. The NDC identifies which product; the label describes what the product does.


Data from the FDA NDC Directory and openFDA drug endpoints. NDC counts are approximate and change daily as products enter and leave the market. Last verified August 2026.

Want drug identification data via API? The MyfitByte API normalizes NDC codes, maps between coding systems, and provides structured drug identity lookups. See our openFDA API guide and Medicare drug spending analysis for related content.

Published on 2026-08-06 · 11 min read

← Back to all articles