What problems could be caused by limits on address field lengths?
Some shipping providers set character limits on their address fields, often between 20 and 40 characters in length. For most fields, the address data we return will be below any character limit. However, in some cases a field's character limit could be exceeded. This can mean that the field will be truncated, which may result in a failed delivery.
Which field is most commonly affected?
Normally the address line 1 field contains the most information.
The longest address line in our US database is 86 characters in length:
Address Line 1
Office Of Governor & Lieutenant Governor, 75 Rev Dr Martin Luther King Jr Blvd Ste 130
But the longest address line in our UK database is an enormous 147 characters long! Theoretically, the longest possible address line in the Royal Mail PAF would be 374 characters long, but it is unlikely that there will ever be an address that is anywhere close to that.
If your address form only contains one address line field, this will be filled with all the address line information. This is what the form would look like when filled with our longest UK address:
Address Line 1
Bybrook Developments (Southern) Ltd, Bowman House Business Centre, Bowman House, Whitehill Industrial Estate, Whitehill Lane, Royal Wootton Bassett
If there is a character limit, the address line may be truncated. For example, if a 40 character limit has been set, address line 1 will be truncated to this:
Bybrook Developments (Southern) Ltd, Bow
For UK addresses, the delivery will still succeed in most cases. This is because each UK postcode covers just a few properties. As long as there is enough information in the address line field to uniquely identify the property, the delivery is likely to succeed. In other countries, however, it is more likely that address line truncation will result in a failed delivery.
How can we solve this?
If you have set a character limit on the address line 1 field, we would suggest moving as many address components as possible to separate fields. You could move the company name to a separate field and create additional address line fields. The rest of the address line information could be split between these additional address lines.
In the case of our UK address example, the problem can be ameliorated by using separate fields for company name and address line 2:
Bybrook Developments (Southern) Ltd
Address Line 1
Bowman House Business Centre, Bowman House, Whitehill Industrial Estate, Whitehill Lane
Address Line 2
Royal Wootton Bassett
This will also be helpful for our longest US address line, reducing the address line to 44 characters:
Office Of Governor & Lieutenant Governor
Address Line 1
75 Rev Dr Martin Luther King Jr Blvd Ste 130
Splitting the address line will reduce the number of addresses that exceed the character limit on the address line 1 field.
However, it is possible to manually construct your own address lines. Our API will return all the address line parts separately, so you can create as many address lines as you want to ensure that none of these lines exceeds your character limit.
If you are using our API directly, you can construct your own address lines from the raw JSON response. Our Address Auto-Complete API will also return two address lines that have been constructed from these parts. In most cases these will probably be below any character limit in length. Note that the line_3, line_4 and line_5 fields in the "Retrieve" response are not currently in use. They will always be empty strings.
Are other address fields affected?
UK company names are limited to 60 characters in the Royal Mail PAF. There are several examples of company names that reach this limit, including this one:
Cambridge & Peterborough Mental Health Partnership NHS Trust
There are a few town names that could exceed a field character limit. For the UK, the town/city field will only be filled with the post town. The longest UK post town name in our database is Appleby-in-Westmorland (22 characters). A UK post town will never exceed 30 characters in length.
For most countries, the town name we return will not exceed 35 characters. Any longer town names are already truncated in our database. The one exception to this is Australia, which has town names that can exceed 35 characters. The longest town name we have for Australia is Robinvale Irrigation District Section B (39 characters).
You may be aware that the longest UK town name belongs to this Anglesey village:
The full name is 58 characters long, but it is commonly shortened to Llanfairpwllgwyngyll which is only 20 characters in length. Royal Mail prefers this shortened form.