How to build a UK address form

Knowledge Base How to build a UK address form

Customer Experience

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 tool

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 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.

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
Horton Kirby

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

Shortest address on PAF

TD11 3RY

Address with a building name and number

Apartment 1
The Jam Works
49 – 51 Fleet Street
L1 4AR

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:

Field Max length Required?
Address line 1 255 Required
Address line 2 255 Not required
Town 35 Required
County 35 Not required
Postcode 8 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

Postcoder address lookup API from Allies returns accurate, postally-correct addresses from a postcode lookup or using autocomplete. It’s the best way to ensure data quality and create a great user experience for your online forms.

Find out more about Postcoder >

If you’re using Postcoder as your address lookup API, you can use the following request to return an address across two address lines, plus town, country and postcode:
      "addressline1": "Allies Computing Ltd",
      "addressline2": "92 St. Faiths Lane",
      "summaryline": "Allies Computing Ltd, 92 St. Faiths Lane, Norwich, Norfolk, NR1 1NE",
      "organisation": "Allies Computing Ltd",
      "premise": "92",
      "street": "St. Faiths Lane",
      "posttown": "Norwich",
      "county": "Norfolk",
      "postcode": "NR1 1NE"

Or you can return the organisation name in a field of its own, rather than within the first address line:
      "addressline1": "92 St. Faiths Lane",
      "addressline2": "",
      "summaryline": "Allies Computing Ltd, 92 St. Faiths Lane, Norwich, Norfolk, NR1 1NE",
      "organisation": "Allies Computing Ltd",
      "premise": "92",
      "street": "St. Faiths Lane",
      "posttown": "Norwich",
      "county": "Norfolk",
      "postcode": "NR1 1NE"

Go to our developer documentation now to try out these different request URLs and more using our test API key.

Receive more great content just like this

Our email newsletter goes out once a month and we will only use your details to send you links to products and articles we think you might be interested in.

You may also like

Live Start Loading NowChatting Offline

Cookie consent

We use some essential cookies to make this website work. We'd like to set additional cookies to help us measure your experience when you view and interact with the website.

Cookie policy