Click here to Skip to main content
Click here to Skip to main content

USPS OneCode Barcodes

, 3 Oct 2008 Apache
Rate this:
Please Sign up or sign in to vote.
USPS One Code - Intelligent Mail Barcode (4-State Customer Barcode) - implementation with VB 2008


This is not a typical article. The focus is on Intelligent Mail Barcode (4 State Customer Barcode) or USPS OneCode implementation as a direct solution for anyone who needs it. The downloads include one VB.NET and one C# class – VS2008 with .NET 3.5 syntax - that generate the string expression of OneCode barcodes and decode a barcode string. The code (uncommented) is a modified fraction of the Pathenon project (covers all known 1D and 2D barcodes) that you will read here on The Code Project in the near future, hopefully. I've noticed that there is no related article, so there you are with an ASAP solution for this new USPS symbology.

Basic Information

Intelligent Mail Barcode, also known as the USPS OneCode Solution or USPS 4-State Customer Barcode (abbreviated 4CB, 4-CB, or USPS4CB), is the latest barcode symbology of the United States Postal Services. It combines routing ZIP code information and tracking information into a single 4-state code. It effectively encodes data from POSTNET and PLANET barcodes into a single barcode while providing a greater range of tracking data.

A 4-state barcode is based on a tracker with ascenders and descenders. The four possible states are tracker (neither ascender nor descender), full (both ascender and descender), ascender only, and descender only. The Intelligent Mail barcode consists of 65 bars as a result of encoding data fields of the following types:

Tracking Code

  • Barcode Identifier as 2 digits (2nd digit must be 0–4)
  • Service Type Identifier as 3 digits
  • Mailer Identifier as 6 or 9 digits and
  • Serial Number as 9 (when used with 6 digit Mailer ID) or 6 (when used with 9 digit Mailer ID) digits

Routing Code

  • Delivery Point ZIP Code as 0, 5, 9, or 11 digits

The above fields, with a maximum of 31 digits in length, are encoded via a complex process (involving big integers and transposed lookups) to bars expressed as a string with 65 characters in the range of A, D, T, F. More information and specifications can be found here.


Note once again that this is not a typical article, but a direct solution for people dealing with this complex barcode symbology.

Thanks for your time.


This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


About the Author


United Kingdom United Kingdom
Passionate "hands on" solution oriented developer, coding since 1983 with proficiency in VB (from v1 to .NET 2010), C#, MS SQL (from v6.0a to 2008 R2), mySQL (from v4 to v6), XML/XSL/XSD, (D)HTML, JavaScript, ... and fluency in PHP, working as a freelancer in GR, IE and UK.

Comments and Discussions

Questionthanks ! you can also try this Pinmemberjacaboo1-Aug-13 17:07 
QuestionAdded the fixes mentioned in the comments to C# code [modified] PinmemberDeepfreezed31-Jul-13 5:55 
Questionbarcoding PinmemberBarcoding House22-Jan-13 17:11 
Questiontransportation barcode Pinmembersteve7g15-Feb-12 23:32 
AnswerRe: transportation barcode Pinmembersybil_9-Oct-12 17:53 
Question.NET Barcode for ASP.NET Pinmembersteve7g15-Feb-12 23:16 
QuestionOneCode Barcode Generator for .NET PinmemberKeepDynamic9-Jan-12 5:07 
GeneralMy vote of 4 Pinmemberncik92-Aug-11 1:52 
GeneralDecoder in plan C PinmemberMember 420048219-Sep-10 16:22 
AnswerRe: Decoder in plan C Pinmemberdrdigit19-Sep-10 22:57 
GeneralBarcode PinmemberJones xxx26-May-09 14:19 
Generalhelp pls.... Pinmemberlakshmi priya.t.n29-Jan-09 18:41 
AnswerRe: help pls.... Pinmemberdrdigit31-Jan-09 12:47 
GeneralCompilation error Pinmemberrobertjb207-Jan-09 10:45 
AnswerRe: Compilation error Pinmemberdrdigit8-Jan-09 6:14 
GeneralHere is another Implementation for .Net (C#) using USPS provided dll and fonts PinmemberMember 422991713-Nov-08 9:43 
QuestionSample application Pinmemberamarbank23-Nov-10 7:38 
GeneralRe: Here is another Implementation for .Net (C#) using USPS provided dll and fonts Pinmembercrobbins6-Jan-11 9:56 
GeneralRe: Here is another Implementation for .Net (C#) using USPS provided dll and fonts PinmemberSid Torres15-Jun-11 9:12 
QuestionRe: Here is another Implementation for .Net (C#) using USPS provided dll and fonts Pinmemberbendece25-Feb-11 17:09 
QuestionIncorrect Decode Example Pinmembervoxdisc10-Nov-08 17:35 
AnswerRe: Incorrect Decode Example Pinmemberbheiland22-May-09 3:15 
GeneralRe: Incorrect Decode Example PinmemberGylfi Ingvason27-May-09 9:59 
GeneralRe: Incorrect Decode Example Pinmemberbheiland27-May-09 14:59 
AnswerRe: Incorrect Decode Example Pinmemberbheiland27-May-09 15:04 
GeneralRe: Incorrect Decode Example Pinmemberbheiland27-May-09 15:23 
GeneralRe: Incorrect Decode Example PinmemberGylfi Ingvason28-May-09 8:02 
GeneralRe: Incorrect Decode Example Pinmemberbheiland28-May-09 12:28 
GeneralRe: Incorrect Decode Example PinmemberGylfi Ingvason29-May-09 6:20 
GeneralRe: Incorrect Decode Example [modified] Pinmemberfwsouthern1-Nov-10 18:31 
GeneralRe: Incorrect Decode Example Pinmemberbheiland14-Apr-11 4:31 
GeneralRe: Incorrect Decode Example [modified] Pinmemberfwsouthern14-Apr-11 4:46 
GeneralThank you for sharing your work... Pinmemberaccusteve4-Nov-08 9:08 
GeneralFailed Test Cases PinmemberMember 452829222-Sep-08 5:56 
AnswerRe: Failed Test Cases Pinmemberdrdigit24-Sep-08 2:39 
QuestionPHP Version? :D Pinmembervoxdisc19-Aug-08 22:30 
GeneralCooool! Pinmembertharpa31-Oct-07 8:48 
QuestionOneCode string Decoder? Pinmemberres416-Oct-07 7:16 
AnswerRe: OneCode string Decoder? Pinmemberdrdigit16-Oct-07 23:53 
GeneralRe: OneCode string Decoder? Pinmembertharpa14-Mar-08 9:00 
NewsOneCode Decoder is finally here Pinmemberdrdigit16-Aug-08 15:36 
GeneralRe: OneCode Decoder is finally here Pinmemberbheiland29-May-09 3:45 
GeneralRe: OneCode Decoder is finally here Pinmembercrobbins6-Jan-11 9:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150123.1 | Last Updated 3 Oct 2008
Article Copyright 2007 by drdigit
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid