Envelope Address Formatter

Addresses to standard, barcode encoded, true size.

  • Publication 28 style
  • IMb barcode encoder
  • True-size PDF
A small stack of plain white envelopes on a light wooden desk with a printed barcode strip curling up from the top envelope.

The guide

An envelope is written for a machine first, so write the address the way the machine reads it

Why the Postal Service asks for capitals and abbreviations, what the four-state barcode actually carries, and which strips of an envelope must stay clear.

  • 65 bars in every Intelligent Mail barcode, each in one of four states
  • 31 digits the most data the barcode can carry
  • 23 positions the line the 1963 two-letter state codes were designed to fit
  • 5/8 inch strip along the bottom of a letter kept clear for the barcode
Read the full guide Fold the guide 9 min · 20 sources

Most letters are read by a person only once, at the very end, when someone opens the door and picks them up. Before that, the reader is a machine moving the envelope past a camera at a speed no clerk could match. The address on the front is written for that machine first. Almost every rule about how an address should look follows from that one fact, and the rules make much more sense once you picture the reader.

How a sorting machine reads the front of a letter

The reader is called a multiline optical character reader. It photographs the address side of a letter, finds the whole address block, reads it, looks the result up in a database of addresses, and sprays a barcode onto the piece. All of that happens in a fraction of a second. From then on, barcode sorters carry the letter the rest of the way, down to the order in which a carrier walks the route.

When the reader fails, the letter does not stop. It gets a hidden fluorescent code on the back, and a picture of its face goes to a remote encoding center, where a person keys in the address from the image. The data is matched back to the letter later. That rescue works, but it is slower and costs people. A clean address avoids it.

So the Postal Service’s advice on addressing reads like advice to a camera. Its official recommendation is upper case block letters, standard formats and abbreviations, and no punctuation at all except the hyphen in a ZIP+4 Code. Only a few other marks survive, because they carry meaning: the slash in a fractional house number such as 123 1/2, the hyphen inside house numbers like those common in Queens and Hawaii, and the decimal point in a street name. None of this is etiquette. Each item removes a way the optical reader can misread a line.

Abbreviations do the same work in a different way. The point is not to save ink. It is to use one agreed spelling for each word, so that what the reader sees can be matched against the Postal Service’s address data. AVENUE, AV and AVEN are all listed spellings of the same suffix, and the Census Bureau’s national street files abbreviate it AVE. NORTHEAST becomes NE in those files. The list of street suffixes the Postal Service recommends is long: from ALLEY to WELLS it runs to about two hundred entries.

The parts of a US address and the order of the last line

A street line breaks into a handful of parts. The Census Bureau’s TIGER/Line street files keep them in separate fields: a direction before the name, a type before it, the base name itself, a type after it and a direction after it. Put a house number at the front and a unit such as APT 4B at the end, and you have the whole delivery line. This page reads that line from the right. The right end holds the most predictable pieces, a unit like APT 4B or a direction like SW, and peeling them off first leaves the street name standing alone.

Spelling alone cannot settle every case. A single letter such as N may be a direction, or simply part of the name of a street called Avenue N. A word like PARK is a suffix on one street and part of the name of another, as in PARK AVENUE. When two suffix words stand together, this page abbreviates only the last one and keeps the first spelled out in the name. Every guess of that kind is shown for you to confirm rather than settled silently.

The last line has its own arithmetic, and it is older than most people assume. Five-digit ZIP Codes arrived on July 1, 1963. That October the Post Office Department published its list of two-letter state abbreviations, and it explained them by line length: the codes were based on a line of at most 23 positions, which a long city name, a multi-letter state abbreviation and the ZIP Code would overrun. Only one code has changed since. Nebraska went from NB to NE in 1969, to avoid confusion with New Brunswick.

The four-digit add-on followed in 1983. A hyphen and four more digits made a full code look like 01234-5678, and that brings the same last line to 28 positions. The recommended form puts no comma between the city and the state, and two spaces before the ZIP Code.

Here is the whole process on a made-up address. Typed casually it reads “Sample Recipient, 123 north main street apartment 4b, Anytown, Massachusetts 01234-5678.” In standard form it becomes three lines: SAMPLE RECIPIENT, then 123 N MAIN ST APT 4B, then ANYTOWN MA followed by two spaces and 01234-5678. Every change traces to a table row. NORTH becomes N, STREET becomes ST, APARTMENT becomes APT, and Massachusetts becomes MA. The last line comes to 22 positions, comfortably inside the 28.

What the four-state barcode carries

The barcode that machines spray, and that large mailers print themselves, is the Intelligent Mail barcode. It has 65 bars, and every bar is one of four shapes. Each has a short middle part called the tracker. It may also have an ascender above, a descender below, both, or neither. This page writes those states as letters: A for an ascender, D for a descender, F for a full bar and T for the tracker alone. The Postal Service required this barcode for automation prices from January 28, 2013. It replaced POSTNET, which carried only routing digits, the ZIP Code and sometimes a delivery point, in full-height and half-height bars.

The barcode holds up to 31 digits, in two pieces. The tracking code is always 20 digits: a two-digit barcode identifier whose second digit runs only from 0 to 4, a three-digit service type, a mailer ID of six or nine digits, and a serial number that fills the rest. The routing code is the ZIP Code with no digits, five, nine or eleven, the last two of eleven being the delivery point. No other length is allowed. Zint, an open-source barcode library, refuses any other length rather than padding the code.

Turning those digits into bars takes six steps. The digits are folded into one large binary number. An 11-bit frame check sequence is computed over 102 of its bits with the generator 0xF35. The number is split into ten codewords, the last by 636, the next eight by 1365, and the first is whatever remains. Two small adjustments follow: the last codeword is doubled, and the first gains 659 when the top check bit is set. Each codeword becomes a 13-bit character from one of two tables, with 1287 and 78 entries. Finally the 130 character bits are dealt out to the 65 bars, two to a bar, through a fixed interleaving table.

Every character has 2, 5, 8 or 11 of its 13 bits set, so flipping any single bit produces something that is not a valid character, which lets a reader detect a misread bar. The two tables this page generates are identical, entry by entry, to the ones Zint ships.

Encoders are checked against a published worked example, and Zint’s own test suite carries it. Take barcode identifier 01, service type 234, mailer ID 567094, serial 987654321 and routing code 01234567891. This page computes the frame check as 751 in hexadecimal and the codewords as 14, 787, 607, 1022, 861, 19, 816, 1294, 35 and 301. Its 65 bars begin AADTF, and every one of them matches the bars Zint’s test expects. A single wrong digit anywhere changes most of them.

That is also why the barcode needs a mailer ID. The tracking code identifies the business sending the mail, and the serial number identifies one piece among its mailings. The Postal Service assigns mailer IDs; six-digit IDs begin with a digit from 0 to 8 and nine-digit IDs begin with 9, so the two lengths can never be confused. A made-up mailer ID produces a barcode that is perfectly well formed and means nothing. A real one is the only kind worth printing.

Envelope sizes and the strips that must stay clear

The rules for where things go on a letter live in the Domestic Mail Manual. Federal regulation incorporates that manual by reference at 39 CFR 111.1, and a change the Postal Service puts out for public comment is printed in full in the Federal Register, so the adopted rules can be read there. Size comes first. The Mail Classification Schedule kept by the Postal Regulatory Commission sets a letter between 5 and 11-1/2 inches long and between 3-1/2 and 6-1/8 inches high. A letter whose length divided by height falls outside 1.3 to 2.5 counts as nonmachinable.

The familiar No. 10 business envelope, 4-1/8 by 9-1/2 inches, sits well inside those limits. So does DL, 110 by 220 millimetres, one of the sizes from ISO 269, a standard withdrawn in 2009 without a replacement. C5, at 162 by 229 millimetres, is taller than 6-1/8 inches, so the letter rules no longer describe it.

None of these zones is printed on a real envelope. Each is measured from the edges, so choosing a different envelope size moves every one of them. The return address goes in the upper left corner, as it does in most countries.

On the face of a letter, the address belongs in an imaginary box called the OCR read area. It starts half an inch in from each side and runs from 5/8 inch to 2-3/4 inches above the bottom edge. Below it lies the barcode clear zone: the bottom 5/8 inch strip, from the right edge back 4-3/4 inches, kept for the barcode. If you print the barcode in that corner yourself, its leftmost bar must sit between 3-1/2 and 4-1/4 inches from the right edge, and the bars start at least 3/16 inch above the bottom. An automation letter may not carry a five-digit or ZIP+4 barcode there; the one in that corner must carry the delivery point.

The alternative is to put the barcode inside the address block, above the recipient’s name. Then it must sit at least 0.028 inch and at most 5/8 inch from that line, with a clear eighth of an inch at each end, and the address block’s bottom line must stay at least 5/8 inch above the bottom edge. The bars themselves have tight tolerances: about 22 to the inch, each between 0.015 and 0.025 inch wide, and a full bar at least 0.125 inch tall. Whatever prints them has to hit those numbers at true size, which is why an envelope file should be printed at 100 percent.

Mail abroad, and what formatting cannot tell you

For mail leaving the country, the rules reverse their emphasis. The bottom line carries the destination country alone, written in full in capital letters, in English. A foreign postal code, if there is one, goes on the line above it. Everything above that follows the habits of the country the letter is going to, which is why a careful formatter leaves those lines as they were typed rather than forcing them into an American shape.

Canada’s provinces and territories have two-letter codes too, and an address within or to Canada puts two spaces between the province code and the postal code.

There is a limit to all of this, and it matters. Standardizing an address makes it readable; it does not make it real. Nothing in the spelling of a line can tell you whether the building exists, which ZIP+4 it carries, or whether a carrier delivers there. Those answers live in the Postal Service’s own address data, which its delivery point validation checks to confirm that an address exists as an active delivery point. A formatter can tidy what you typed and encode the numbers you hold. It cannot vouch for the destination.

Sources

Every source consulted for this guide. Links checked October 31, 2026.

  1. Address format by country and area Wikipedia
  2. United States Postal Service Wikipedia
  3. Street suffix Wikipedia
  4. List of U.S. state and territory abbreviations Wikipedia
  5. Canadian postal abbreviations for provinces and territories Wikipedia
  6. TIGER/Line Shapefiles Technical Documentation, 2024 U.S. Census Bureau
  7. imail.c - Handles Intelligent Mail (aka OneCode) for USPS Zint barcode library, BSD 3-Clause licence
  8. test_imail.c - Intelligent Mail encoder tests Zint barcode library, BSD 3-Clause licence
  9. Mail Classification Schedule (Revisions Through July 12, 2026) Postal Regulatory Commission
  10. 39 CFR 111.1 - Incorporation by reference; Domestic Mail Manual Code of Federal Regulations, 2025 edition, govinfo.gov
  11. Classification Reform; Implementation Standards (61 FR 10068) Federal Register, March 12, 1996, govinfo.gov
  12. Changes to the Domestic Mail Manual to Implement Docket No. R2001-1 (67 FR 18684) Federal Register, April 16, 2002, govinfo.gov
  13. Implementation of New Standards for Intelligent Mail Barcodes (73 FR 49333) Federal Register, August 21, 2008, govinfo.gov
  14. POSTNET Barcode Discontinuation (77 FR 26185) Federal Register, May 3, 2012, govinfo.gov
  15. Intelligent Mail barcode Wikipedia
  16. ZIP Code Wikipedia
  17. Envelope Wikipedia
  18. Return address Wikipedia
  19. Multiline optical-character reader Wikipedia
  20. POSTNET Wikipedia