Knowledge Base How to build a UK address form
All you need to know about capturing and storing UK addresses
Address finder tools support any address, allow you to store the composite parts of the full address in your database, and provide a quick and easy solution for your users.
Below, we’ve detailed what we consider the best practice when building a generic postal address form in HTML.
Address finder design
To minimise clutter, we recommend you start with a postcode field and a “Find address” button at the top of your form, with an “Enter address manually” link underneath.
This groups your user’s options at the top of the form, and ensures that they don’t complete a form manually only to scroll down and find that there was a faster way.
Behind the scenes, code your form so that when a user enters a postcode and clicks on the button, it sends their input to Postcoder.
If the API returns with some matches, display them in a list and ask the user to select their address. Use their selection to populate the fields on your form, making the fields editable so changes can be made if needed.
If there are no matches, you can do one of two things: 1) ask the user to check the postcode and try again or 2) show all the fields on your form and ask them to fill in their address manually.
Address form layout
Once Postcoder has found some address suggestions and your user has selected their own, you should present their address in a way that they will recognise and allows you to store it reliably if they wish to make any changes.
We recommend using the following fields:
Address line 1
Address line 2
County is not required by Royal Mail for deliveries but it may still be used by your business. For instance, for segmenting customer groups or for distrubuting leads to county-based sales teams.
If your users need to provide an organisation name, you may wish to include a separate “Organisation name” field at the top of your address form.
Enter address manually
Don’t forget the “Enter address manually” link; it is useful to those users that struggle to find their address using the automatic lookup. Clicking the link should show all the fields on your form.
Example UK addresses
Here are two typical residential addresses in the UK:
195 Ber Street
20 Rashleigh Way
There are, however, some addresses on Royal Mail’s Postcode Address File (PAF) that look quite different:
Longest address on PAF
Isle of Man Government Office of Human Resources
Learning Education and Development
The Lodge Education and Training Centre
ISLE OF MAN
Shortest address on PAF
Address with a building name and number
The Jam Works
49 – 51 Fleet Street
UK postcode input vs as-you-type autocomplete
Consider what would work best for your users. Postcode input still provides the fastest way to fill in a UK address, primarily because there are an average of just 15 addresses assigned to every postcode.
However don’t rule out predictive address autocomplete as it can be easier to use, particularly on mobile devices with limited screen space. As-you-type autocomplete is becoming an increasingly familiar way to complete forms, even if it isn’t necessarily faster.
Read more: how to ensure a good user experience in the UK postcode lookup process
Field lengths and mandatory fields
When designing your form and the underlying data structure to store your addresses, use the following field lengths and mandatory checks:
|Address line 1||255||Required|
|Address line 2||255||Not required|
Every UK address will always have a first address line, a town / city and a postcode. If you are less concerned with data quality and more concerned with helping your users get to the next step, you may decide to avoid mandatory fields altogether.
Using Postcoder to lookup addresses
If you’re planning to use Postcoder as your address lookup API, the following request will return addresses across three address lines plus town, country and postcode:
Or with the organisation name in a field of its own, rather than within the first address line: