Developer·4 min read

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.

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.

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.

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 handle 10-digit vs 11-digit NDC in a database? Store as 11-digit (5-4-2 format) with dashes stripped. Convert on input. This eliminates the ambiguity problem at the storage layer.

Can I map NDC to drug price? NDC is the key used in CMS pricing files (NADAC, ASP). The NDC ties directly to wholesale and retail pricing data published by CMS.

Published on 2026-08-06 · 4 min read

← Back to all articles