
Updated December 2026. Codes and rules verified against carrier documentation; see references at the end.
To calculate USPS dimensional weight in code, round each side up to the next whole inch, multiply length by width by height, and if the result is over 1,728 cubic inches, divide by 139 and round up to the next pound. UPS uses the same 139 divisor for Daily Rates (166 for domestic Retail Rates), but it rounds each side to the nearest inch and applies DIM weight at any size. The billable weight is the greater of actual and DIM weight. USPS cubic pricing is a separate calculation: round each side down to the nearest 1/4 inch, convert to cubic feet, and bucket into 0.1 cubic foot tiers.
The rules below took effect July 12, 2026. They are the same in DMM 223 (Priority Mail commercial), 283 (USPS Ground Advantage commercial), 213 (Priority Mail Express), 253 (Parcel Select) and the retail sections 113, 123 and 133.
Actual weight is rounded up to the next whole pound for Priority Mail. USPS Ground Advantage commercial prices under 1 pound use 4, 8, 12 and 15.999 ounce increments, so the pound-based billable function below applies to packages of 1 pound and up.
One inconsistency: as of December 2026, DMM 223.1.4.3 (Priority Mail commercial, nonrectangular) still reads "round off" and divisor 166. Check it before you hard-code nonrectangular Priority Mail.
UPS measures each side at its longest point and rounds to the nearest whole inch (1.00 to 1.49 becomes 1, 1.50 to 1.99 becomes 2), with a 1 inch minimum per side. Multiply the sides, divide by 139 (Daily Rates) or 166 (domestic Retail Rates; the Retail guide uses 139 for exports), and round any fraction up to the next pound. Actual weight also rounds up to the next pound, and billable weight is the greater of the two. UPS says DIM weight may apply to all domestic and international package services, with no 1 cubic foot threshold, so a small, light box can still bill on DIM weight. The "How to measure" section of the same UPS page says to round each side up (1.01 becomes 2), which conflicts with its DIM formula and the Rate and Service Guide. The code follows the guide; round up instead for a conservative estimate.
| Rule | USPS (from July 12, 2026) | UPS |
|---|---|---|
| Side rounding | Up to next whole inch | Nearest whole inch (.50 rounds up), minimum 1 inch |
| When DIM applies | Volume over 1,728 cu in | Any package |
| Divisor | 139 | 139 Daily Rates, 166 domestic Retail Rates |
| Nonrectangular | Volume x 0.785 | Measure at extreme points as if in a rectangular box |
| Result rounding | Up to next pound | Up to next pound |
| Cap | DIM over 70 lb pays the 70 lb price | None stated; 150 lb max actual weight |
Use exact arithmetic so float noise never pushes a side over an inch boundary. Python's built-in round() uses banker's rounding (round(12.5) is 12), which is wrong for UPS, so the code rounds half up explicitly.
from fractions import Fraction as F
import math
def _f(x):
return F(str(x)) # exact: 12.1 -> 121/10
def _half_up(x):
return math.floor(x + F(1, 2)) # UPS "nearest inch"; not round()
def usps_dim_weight(l, w, h, nonrectangular=False):
dims = [math.ceil(_f(d)) for d in (l, w, h)] # round UP to whole inch
vol = F(dims[0] * dims[1] * dims[2])
if nonrectangular:
vol *= F(785, 1000)
if vol <= 1728:
return None # DIM does not apply
return min(math.ceil(vol / 139), 70) # 70 lb price cap
def usps_billable_lb(actual_lb, l, w, h, nonrectangular=False):
dim = usps_dim_weight(l, w, h, nonrectangular)
return max(math.ceil(_f(actual_lb)), dim or 0)
def ups_dim_weight(l, w, h, divisor=139): # 166 for Retail Rates
dims = [max(1, _half_up(_f(d))) for d in (l, w, h)]
return math.ceil(F(dims[0] * dims[1] * dims[2]) / divisor)
def ups_billable_lb(actual_lb, l, w, h, divisor=139):
return max(math.ceil(_f(actual_lb)), ups_dim_weight(l, w, h, divisor))
JavaScript has no exact decimal type, so convert inches to hundredths and keep the comparisons in integers. Billable weight is then Math.max(Math.ceil(actualLb), dim ?? 0), as in the Python version.
const hundredths = (x) => Math.round(x * 100); // assumes input to 0.01 inch
const ceilDiv = (a, b) => Math.floor((a + b - 1) / b); // integers only
export function uspsDimWeight(l, w, h, { nonrectangular = false } = {}) {
const [a, b, c] = [l, w, h].map((d) => ceilDiv(hundredths(d), 100));
let vol = a * b * c;
if (nonrectangular) vol = (vol * 785) / 1000;
if (vol <= 1728) return null;
return Math.min(Math.ceil(vol / 139 - 1e-9), 70);
}
export function upsDimWeight(l, w, h, divisor = 139) {
const [a, b, c] = [l, w, h].map((d) =>
Math.max(1, Math.floor((hundredths(d) + 50) / 100))); // .50 rounds up
return ceilDiv(a * b * c, divisor);
}
Produced by running the functions above; Python and JavaScript gave identical results.
| Box (inches), actual weight | USPS DIM | USPS billable | UPS DIM (139) | UPS DIM (166) | UPS billable (139) |
|---|---|---|---|---|---|
| 12 x 12 x 12, 4 lb | none (exactly 1,728) | 4 | 13 | 11 | 13 |
| 12 x 12 x 12.1, 4 lb | 14 | 14 | 13 | 11 | 13 |
| 14 x 10 x 8, 2.2 lb | none | 3 | 9 | 7 | 9 |
| 18 x 14 x 12, 6 lb | 22 | 22 | 22 | 19 | 22 |
| 16.4 x 12.6 x 10.5, 3 lb | 18 | 18 | 17 | 14 | 17 |
| 24 x 18 x 18, 10 lb | 56 | 56 | 56 | 47 | 56 |
| 36 x 24 x 24, 15 lb | 70 (capped) | 70 | 150 | 125 | 150 |
In the 12 x 12 x 12.1 row, USPS rounds 12.1 up to 13 (1,872 cu in) while UPS rounds it to 12 (1,728 cu in). A nonrectangular 20 x 20 x 10 parcel at USPS is 4,000 x 0.785 = 3,140 cu in, or 23 lb.
Per DMM 223.1.3 and 283.1.3:
from fractions import Fraction as F
import math
CUBIC_MAX = {"priority": F(1, 2), "ground_advantage": F(1)}
def quarter_down(x):
return F(math.floor(F(str(x)) * 4), 4) # 12.375 -> 12.25
def usps_cubic_tier(l, w, h, weight_lb, product="priority"):
s = sorted((quarter_down(d) for d in (l, w, h)), reverse=True)
if s[0] > 22 or F(str(weight_lb)) > 20:
return None
cuft = s[0] * s[1] * s[2] / 1728
if cuft > CUBIC_MAX[product]:
return None
return max(F(math.ceil(cuft * 10), 10), F(1, 10)) # 0.1 steps; float() for display
def usps_soft_pack_tier(length, width): # also check weight <= 20 lb
l, w = quarter_down(length), quarter_down(width)
if max(l, w) > 22:
return None # longest side over 22 in
total = l + w
for limit, tier in [(21, "0.1"), (27, "0.2"), (31, "0.3"), (34, "0.4"), (36, "0.5")]:
if total <= limit:
return tier
return None # over 36 in: not cubic
| Box (inches), weight | Priority Mail tier | Ground Advantage tier |
|---|---|---|
| 6-1/8 x 5-7/8 x 6-3/8, 2 lb (DMM's own example) | 0.2 | 0.2 |
| 8 x 6 x 4, 1 lb | 0.2 | 0.2 |
| 10 x 8 x 6, 3 lb | 0.3 | 0.3 |
| 12 x 10 x 6, 5 lb | 0.5 | 0.5 |
| 12 x 12 x 8, 8 lb | not eligible (over 0.5) | 0.7 |
| 12 x 12 x 12, 15 lb | not eligible | 1.0 |
| 23 x 6 x 6, 4 lb | not eligible (side over 22) | not eligible |
| 10 x 8 x 6, 21 lb | not eligible (over 20 lb) | not eligible |
Soft packs from the same run: 10 x 13 is tier 0.2, 12 x 15.5 is 0.3, 14.5 x 19 is 0.4, 10-1/8 x 10.9 (10 + 10.75 = 20.75) is 0.1, and 19 x 19 (over 36) and 23 x 10 (side over 22) are not eligible.
In the USPS Domestic Prices API v3, cubic results come back with rate indicators such as C1 to C5 (Cubic Pricing Tier 1 to 5), CP (Cubic Parcel) and P5 to P9 (Cubic Soft Pack Tier 1 to 5). In the Labels API, the matching packagingType values are CUBIC_PARCELS and CUBIC_SOFT_PACK.
Priority Mail (DMM 223.1.10) and USPS Ground Advantage commercial (DMM 283.1.7) charge nonstandard fees for:
A length fee and a cube fee can both apply: 24 x 18 x 18 triggers both.
| Limit | USPS | UPS |
|---|---|---|
| Max weight | 70 lb | 150 lb actual weight |
| Max size | 108 in length plus girth; 130 in for Ground Advantage, Parcel Select Destination Entry and USPS Connect Local | 165 in length plus girth; 108 in max length |
| Oversized / large package | Ground Advantage and Parcel Select oversized price over 108 in up to 130 in | Large Package: length plus girth over 130 in or length over 96 in, with a minimum billable weight (see the current UPS Rate and Service Guide) |
Not for the final rate. The USPS Domestic Prices API v3 takes dimensions and uses the greater of DIM and actual weight. Local functions help with box selection, checkout estimates and spotting nonstandard fees early.
139 for rectangular parcels in every 2026 DMM section. 166 appears only in the nonrectangular rule of DMM 223.1.4.3 for Priority Mail commercial, which still shows the older text as of December 2026.
They are separate price structures: cubic is priced by tier and zone, weight-based by billable weight and zone. Because cubic rounds sides down and DIM rounds them up, a 12 x 12 x 12.1 box under 20 lb is tier 1.0 for Ground Advantage cubic but 14 lb DIM by weight. Quote both and buy the lower one.
Ship.com gives you USPS and UPS labels at up to 89% off USPS and up to 87% off UPS without your own carrier accounts, from your code through the REST API or from AI agents through the MCP server. Every account starts with a 30-day free trial, no credit card required. Read the Ship MCP setup guide or See plans and pricing.
Related reading: USPS dimensional weight rules for 2026, USPS cubic pricing explained, and the Ship.com shipping calculator.