Random UK Town & City Generator
A UK town generator selects real British post towns at random and returns the county, country, region, postcode areas and dialling code that belong to each.
Every town in the list is a genuine Royal Mail post town, so the output is suitable as reference data as well as test data. Each result carries the county in the correct terminology for its country — ceremonial county in England, council area in Scotland, preserved county in Wales, traditional county in Northern Ireland.
Options
| Name | Type | Default | Description |
|---|---|---|---|
country | enum | — | Filter by UK country. |
slug | string | — | Return a single post town by slug. |
Use cases
- Dropdown and filter fixtures: Populate town selectors and location filters with real British place names.
- Regional test coverage: Make sure a test suite covers all four UK countries rather than only English addresses.
- Content and demo data: Generate believable location data for demos, tutorials and screenshots.
REST API
GET /api/v1/locations
curl "https://ukaddressgenerator.org/api/v1/locations?country=Wales"
{
"status": "success",
"total": 57,
"data": [
{ "slug": "cardiff", "name": "Cardiff", "postTown": "CARDIFF", "country": "Wales", "county": "South Glamorgan", "countyType": "Preserved county", "region": "Wales", "postcodeAreas": ["CF"], "districts": ["CF3","CF5","CF10","CF11","CF14","CF23","CF24"], "diallingCode": "029", "lat": 51.4816, "lng": -3.1791 }
]
}
Frequently asked questions
- Are these real towns?
Yes. Only the selection is random; every town, county and postcode area in the output is real.
- What is a post town?
A post town is the Royal Mail routing label written in capitals on an address. It is not the same as a local-authority area, and it may differ from the name people use for where they live.
Post towns, cities and the difference between them
Why UK location data does not behave like a city field · 250 words
1. Post town is a routing label
Royal Mail assigns each address a post town, written in capitals on the label. It is not a legal or administrative entity. Some post towns cover several settlements; some cities are split across more than one post town; and some post towns share a name with a completely different place elsewhere in the UK.
NEWPORT is a post town in Wales, in Shropshire and on the Isle of Wight. BANGOR exists in Gwynedd and in County Down. Only the postcode separates them, which is why a "city" text field alone is never sufficient for UK address matching.
2. City status is unrelated
City status in the UK is granted by the monarch and has nothing to do with size or postal geography. St Davids has fewer than 2,000 residents and is a city; Reading has over 170,000 and is not. Nothing in an address depends on city status, so do not model it as a field.
3. Using town data in tests
Pick towns from all four countries. A test suite that only exercises English addresses will miss Scottish council areas, Welsh-language street names and the single BT postcode area that covers Northern Ireland — three of the most common sources of production bugs in UK address handling.
curl "/api/v1/locations?country=Northern%20Ireland"
More questions
- Should I store the post town or the city name?
Store the post town for anything postal, because that is what appears on the label. Store a separate display name if your interface needs one.