UK Random Address Generator
A UK random address generator creates fictional British postal addresses that follow Royal Mail addressing conventions and use real postcode districts, for use as software test data.
Each address is assembled from one registry entry, so the postcode district, post town, dependent locality, county, country, coordinates and dialling code always agree with one another. Building numbers, building names, recipient names and the inward half of the postcode are generated, which keeps every result fictional and non-deliverable while still passing UK postcode validation. Output can be copied one field at a time or exported in bulk as JSON, CSV, TSV, SQL, XML or Royal Mail envelope text.
Options
| Name | Type | Default | Description |
|---|---|---|---|
count | integer | 10 | How many records to return, from 1 to 1000. |
country | enum | — | Restrict generation to one UK country. |
location | string | — | Post-town slug, for example "manchester" or "cardiff". Takes precedence over country. |
type | enum | all | Delivery point type. |
format | enum | json | Response format. |
subBuilding | boolean | true | Set to false to omit flat, unit and suite lines. |
county | boolean | true | Set to false to omit the optional county line, as Royal Mail permits. |
phone | boolean | true | Set to false to omit telephone numbers. |
recipient | boolean | true | Set to false to omit recipient names. |
tableName | string | uk_addresses | Table name used by format=sql. Letters, digits and underscores only. |
seed | integer | — | Optional. Any integer. The same seed with the same options always returns the same records. |
Use cases
- Checkout and address form testing: Exercise postcode validation, address line limits, optional county handling and buildings with names instead of numbers without touching customer data.
- Database and CI seeding: Populate a staging database with realistic UK addresses using the SQL export, or seed fixtures reproducibly with the seed parameter.
- Delivery and pricing logic: Test postcode-based delivery zones, offshore and Highlands surcharges and Northern Ireland routing with addresses drawn from the right districts.
- Design and documentation: Fill mock-ups, screenshots and user guides with believable British addresses that cannot be mistaken for a real customer.
REST API
GET /api/v1/addresses/random
curl "https://ukaddressgenerator.org/api/v1/addresses/random?count=10&country=Wales"
{
"status": "success",
"count": 1,
"query": { "count": 1, "country": "ALL", "location": "manchester", "type": "residential" },
"data": [
{
"id": "uk_addr_0001_8f3k2",
"recipientName": "Isla Robertson",
"buildingNumber": "42",
"street": "Church Lane",
"locality": "Didsbury",
"postTown": "MANCHESTER",
"county": "Greater Manchester",
"postcode": "M20 4TH",
"outwardCode": "M20",
"inwardCode": "4TH",
"postcodeArea": "M",
"postcodeDistrict": "M20",
"postcodeSector": "M20 4",
"country": "England",
"region": "North West England",
"countryCode": "GB",
"latitude": 53.4791,
"longitude": -2.2503,
"timezone": "Europe/London",
"phone": "0161 496 0287",
"phoneE164": "+441614960287",
"type": "residential",
"isFictional": true,
"formattedSingleLine": "42 Church Lane, Didsbury, Manchester, M20 4TH",
"formattedMultiLine": "42 Church Lane\nDidsbury\nMANCHESTER\nGreater Manchester\nM20 4TH"
}
]
}
Frequently asked questions
- Are the generated UK addresses real?
No. The post town, postcode district, locality, county and country are real, but the building, the street pairing, the recipient and the last three characters of the postcode are generated. Nothing produced is a live Royal Mail delivery point.
- Will the addresses pass postcode validation?
Yes. Each postcode combines a real outward code with an inward code that follows the Royal Mail structural rules, including the excluded letters, so standard validators accept it.
- Can I generate addresses for a specific city?
Yes. Choose a post town in the generator, or open the dedicated page for that town, or call the API with ?location=<slug>.
- How many addresses can I generate at once?
Up to 1,000 per request, in the interface and through the API.
A practical guide to synthetic UK address data
What makes a generated British address usable in a test suite · 500 words
1. What a UK address is actually made of
Royal Mail's addressing model has more levels than most database schemas allow for. From the top of the label down: addressee, organisation, sub-building (Flat 4), building name (Victoria House), building number and thoroughfare (12 High Street), dependent locality (Didsbury), post town (MANCHESTER), county (optional) and postcode.
Two of these regularly break systems designed elsewhere. First, a property may have a name and no number — "Rose Cottage, Church Lane" is a complete and valid address. Second, the post town is a Royal Mail routing label, not a city or a council area, which is why an address in Hove uses the post town HOVE rather than BRIGHTON.
Every address this generator produces follows that layout, with the post town in capitals and the postcode on its own line.
2. Where realism comes from
Realism is not about clever street names; it is about consistency. The generator picks one post town, then one of that town's real postcode districts, and reads the locality, county, country, ONS region, coordinates and dialling code from the same record. That is what stops the classic failure of pairing a Manchester street with a Cardiff postcode.
Street names are drawn from names that recur across the entire country — High Street, Church Lane, Station Road, Victoria Road, The Avenue — precisely because they are not tied to one place. Welsh post towns occasionally receive Welsh-language street names, and Scottish addresses occasionally use Scottish thoroughfare types such as Wynd and Brae, because those patterns are genuinely regional.
3. Where the fiction is deliberately placed
A postcode's inward code — the digit and two letters after the space — narrows delivery to roughly fifteen addresses. Generating it at random produces a postcode that is structurally perfect and, overwhelmingly likely, not a live delivery point.
That is the whole trick: real outward code, generated inward code. Your validator accepts it; the postal system does not recognise it. Building numbers, building names, recipient names and organisation names are generated for the same reason.
4. Using it from the command line
The same generator is available over HTTP with no API key. Add a seed when you need the same fixtures on every CI run.
# 25 Welsh commercial addresses as CSV
curl "/api/v1/addresses/random?count=25&country=Wales&type=commercial&format=csv"
# Reproducible fixtures for a snapshot test
curl "/api/v1/addresses/random?count=10&seed=1234"
# A single Belfast address without the county line
curl "/api/v1/addresses/random?count=1&location=belfast&county=false"
5. Modelling the data
Store the parts, not just the formatted string. A single "address" text column makes it impossible to test sorting, delivery zones or label printing properly.
CREATE TABLE addresses (
id BIGSERIAL PRIMARY KEY,
organisation VARCHAR(160),
sub_building VARCHAR(60),
building_name VARCHAR(120),
building_number VARCHAR(12), -- string: 12A, 221B, 1/2 are all real
thoroughfare VARCHAR(120) NOT NULL,
locality VARCHAR(120),
post_town VARCHAR(60) NOT NULL,
county VARCHAR(60), -- optional under Royal Mail rules
postcode VARCHAR(8) NOT NULL,
country VARCHAR(20) NOT NULL
);
More questions
- Can I use generated addresses in a production database?
Only as placeholder or demo data that is clearly labelled. They are not deliverable, so anything that results in a physical delivery, a credit decision or an identity check must not use them.
- Do the coordinates point at the generated address?
No. They are the town centre with a small random offset, which puts the point in the right town without identifying a property.
- Why do some addresses have no county line?
Because Royal Mail does not require one, and London addresses never use one. You can turn the county line on or off in the generator options.