All Collections
Technical
Address field lengths
Address field lengths

Could our address data exceed your character limit?

Updated over a week ago

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

City

Saint Paul

State

Minnesota

ZIP

55155-1611

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

Town

Swindon

Postcode

SN4 7DB

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.

Our JavaScript library will automatically split the address line into parts if there are also company and address line 2 fields. Note that you will need to set the id/name of each new field in your configuration for Address Auto-Complete or Postcode Lookup.

In the case of our UK address example, the problem can be ameliorated by using separate fields for company name and address line 2:

Company Name

Bybrook Developments (Southern) Ltd

Address Line 1

Bowman House Business Centre, Bowman House, Whitehill Industrial Estate, Whitehill Lane

Address Line 2

Royal Wootton Bassett

Town

Swindon

Postcode

SN4 7DB

This will also be helpful for our longest US address line, reducing the address line to 44 characters:

Company

Office Of Governor & Lieutenant Governor

Address Line 1

75 Rev Dr Martin Luther King Jr Blvd Ste 130

City

Saint Paul

State

Minnesota

ZIP

55155-1611

Splitting the address line will reduce the number of addresses that exceed the character limit on the address line 1 field.

Currently, we only provide two preconstructed address lines. If you are using our JavaScript library, you are able to set the form elements to use for address lines 1 and 2, but it does not support any additional address lines.

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 JavaScript library for Address Auto-Complete or Postcode Lookup, you can do this using one of our callback functions that are executed when the form fields are populated. These allow you to access the address components individually. You should use onResultSelected for Address Auto-Complete or on_result_selected for Postcode Lookup.

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.

Our JavaScript library for Address Auto-Complete has a limitToMaxLength option. This will limit the length of the data we use to fill the line 1, line 2 and company fields. If the length of the address data exceeds the field's limit, it will be truncated. Currently this feature is supported by our BigCommerce plugin, and it is also available if you are developing a custom integration using our JavaScript library.


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:

Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch.

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.

Did this answer your question?