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.

Postcode to address finder

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
Town
County
Postcode

Counties

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.

Organisation names

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
NORWICH
NR1 3HB

20 Rashleigh Way
Horton Kirby
DARTFORD
DA4 9DJ

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
Braddan Road
Strang
Douglas
ISLE OF MAN
IM4 4QN

Shortest address on PAF
Elba
DUNS
TD11 3RY

Address with a building name and number
Apartment 1
The Jam Works
49 – 51 Fleet Street
LIVERPOOL
L1 4AR

UK postcode input vs as-you-type autocomplete

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.

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:

FieldMax lengthRequired?
Address line 1255Required
Address line 2255Not required
Town35Required
County35Not required
Postcode8Required

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:

http://ws.postcoder.com/pcw/PCW45-12345-12345-1234X/address/uk/NR147PZ?lines=3&format=json

Or with the organisation name in a field of its own, rather than within the first address line:

http://ws.postcoder.com/pcw/PCW45-12345-12345-1234X/address/uk/NR147PZ?lines=3&exclude=organisationname&format=json

Article last updated: