How to build a UK address form

All you need to know about capturing and storing UK addresses

In the UK, there are three main ways to capture an address from a user:

1. Using a single text box

Single text field address form

Supports any address and is easy to copy-and-paste into
Difficult to split address into separate parts later on

2. Using individual fields

Multiple address element fields form

Each part of an address can be stored easily in your database
Forces the user to think about where to enter the different parts of their address

3. Using an address finder

Postcode to address finder

Each part of an address can be stored easily in your database
Quick and easy for the user to provide a reliable address

Which method is best?

To capture an accurate address in the shortest amount of time, we recommend using an address finder. Ultimately, you should choose the option that works best with your users.


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 that look quite different:

Long address
Department for Environment Food & Rural Affairs (D E F R A)
State Veterinary Service
Animal Health Office
Hadrian House
Wavell Drive
Rosehill Industrial Estate
CARLISLE
CA1 2TB

Short address
Elba
DUNS
TD11 3RY

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


Fields for your address form


To ensure your users have the best chance of entering their address into your form, we recommend using the following fields:

Address line 1
Address line 2
Address line 3
Town
County
Postcode

Counties

County is not required by Royal Mail but it may still be used by your business. For instance, for segmenting customers or for distributing 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.


How to lay out your address form


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

Behind the scenes, code your form so that when a user enters a postcode and clicks on the button, it invokes a request to an address lookup API like PostCoder Web.

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 and make the fields editable so they can make changes if needed.

Address fields populated using an address finder

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.

Enter address manually

The "Enter address manually" link 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.

UK postcode input vs as-you-type autocomplete

We believe 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
Address line 3255Not required
Town35Required
County35Not required
Postcode8Required

Every UK address will always have a first address line, a town / city and a postcode. If you’re 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 Web to lookup addresses


If you're planning to use PostCoder Web 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

Useful articles and guides