Address

Module to generate addresses and locations.

Building Number

Generates a random building number.

Returns: string

faker.address.buildingNumber(): string
faker.address.buildingNumber() // => "5786"
faker.address.buildingNumber() // '379'

Cardinal Direction

Returns a random cardinal direction (north, east, south, west).

Parameters

NameTypeDefaultDescription
useAbbrbooleanfalse

If true this will return abbreviated directions (N, E, etc). Otherwise this will return the long name.

Returns: string

faker.address.cardinalDirection(useAbbr: boolean = false): string
faker.address.cardinalDirection() // => "South"
faker.address.cardinalDirection() // 'North'
faker.address.cardinalDirection(false) // 'South'
faker.address.cardinalDirection(true) // 'N'

City

Generates a random localized city name.

Parameters

NameTypeDefaultDescription
format?number | string

The format to use. Can be either the index of the format to use or any method provided by faker wrapped in {{}}, e.g. {{name.firstName}} in order to build the city name.

If no format string is provided one of the following is randomly used:

  • {{address.cityPrefix}} {{name.firstName}}{{address.citySuffix}}
  • {{address.cityPrefix}} {{name.firstName}}
  • {{name.firstName}}{{address.citySuffix}}
  • {{name.lastName}}{{address.citySuffix}}
  • {{address.cityName}} when city name is available

Returns: string

faker.address.city(format?: number | string): string
faker.address.city() // => "Larrymouth"
faker.address.city() // 'Gleasonbury'
faker.address.city(2) // 'Jadenshire'

City Name

Returns a random localized city name.

Returns: string

faker.address.cityName(): string
faker.address.cityName() // => "Menifee"
faker.address.cityName() // 'San Rafael'

City Prefix

Returns a random localized city prefix.

Returns: string

faker.address.cityPrefix(): string
faker.address.cityPrefix() // => "New"
faker.address.cityPrefix() // 'East'

City Suffix

Returns a random localized city suffix.

Returns: string

faker.address.citySuffix(): string
faker.address.citySuffix() // => "stead"
faker.address.citySuffix() // 'mouth'

Country

Returns a random country name.

Returns: string

faker.address.country(): string
faker.address.country() // => "Malta"
faker.address.country() // 'Greece'

Country Code

Returns a random country code.

Parameters

NameTypeDefaultDescription
alphaCode'alpha-2' | 'alpha-3''alpha-2'

The code to return. Can be either 'alpha-2' (2 letter code) or 'alpha-3' (three letter code).

Returns: string

faker.address.countryCode(alphaCode: 'alpha-2' | 'alpha-3' = 'alpha-2'): string
faker.address.countryCode() // => "MA"
faker.address.countryCode() // 'SJ'
faker.address.countryCode('alpha-2') // 'GA'
faker.address.countryCode('alpha-3') // 'TJK'

County

Returns a random localized county.

Returns: string

faker.address.county(): string
faker.address.county() // => "Borders"
faker.address.county() // 'Cambridgeshire'

Direction

Returns a random direction (cardinal and ordinal; northwest, east, etc).

Parameters

NameTypeDefaultDescription
useAbbrbooleanfalse

If true this will return abbreviated directions (NW, E, etc). Otherwise this will return the long name.

Returns: string

faker.address.direction(useAbbr: boolean = false): string
faker.address.direction() // => "Northeast"
faker.address.direction() // 'Northeast'
faker.address.direction(false) // 'South'
faker.address.direction(true) // 'NE'

Latitude

Generates a random latitude.

Parameters

NameTypeDefaultDescription
maxnumber90

The upper bound for the latitude to generate.

minnumber-90

The lower bound for the latitude to generate.

precisionnumber4

The number of decimal points of precision for the latitude.

Returns: string

faker.address.latitude(max: number = 90, min: number = -90, precision: number = 4): string
faker.address.latitude() // => "8.7864"
faker.address.latitude() // '-30.9501'
faker.address.latitude(10, -10, 5) // '2.68452'

Longitude

Generates a random longitude.

Parameters

NameTypeDefaultDescription
maxnumber180

The upper bound for the longitude to generate.

minnumber-180

The lower bound for the longitude to generate.

precisionnumber4

The number of decimal points of precision for the longitude.

Returns: string

faker.address.longitude(max: number = 180, min: number = -180, precision: number = 4): string
faker.address.longitude() // => "17.5729"
faker.address.longitude() // '-154.0226'
faker.address.longitude(10, -10, 5) // '-4.03620'

Nearby GPSCoordinate

Generates a random GPS coordinate within the specified radius from the given coordinate.

Parameters

NameTypeDefaultDescription
coordinate?[latitude: number, longitude: number]

The original coordinate to get a new coordinate close to. If no coordinate is given, a random one will be chosen.

radiusnumber10

The maximum distance from the given coordinate to the new coordinate.

isMetricbooleanfalse

If true assume the radius to be in kilometers. If false for miles.

Returns: [latitude: string, longitude: string]

faker.address.nearbyGPSCoordinate(coordinate?: [latitude: number, longitude: number], radius: number = 10, isMetric: boolean = false): [latitude: string, longitude: string]
faker.address.nearbyGPSCoordinate() // => ["8.7864","33.4241"]
faker.address.nearbyGPSCoordinate() // [ '33.8475', '-170.5953' ]
faker.address.nearbyGPSCoordinate([33, -170]) // [ '33.0165', '-170.0636' ]
faker.address.nearbyGPSCoordinate([33, -170], 1000, true) // [ '37.9163', '-179.2408' ]

Ordinal Direction

Returns a random ordinal direction (northwest, southeast, etc).

Parameters

NameTypeDefaultDescription
useAbbrbooleanfalse

If true this will return abbreviated directions (NW, SE, etc). Otherwise this will return the long name.

Returns: string

faker.address.ordinalDirection(useAbbr: boolean = false): string
faker.address.ordinalDirection() // => "Southeast"
faker.address.ordinalDirection() // 'Northeast'
faker.address.ordinalDirection(false) // 'Northwest'
faker.address.ordinalDirection(true) // 'NE'

Secondary Address

Generates a random localized secondary address. This refers to a specific location at a given address such as an apartment or room number.

Returns: string

faker.address.secondaryAddress(): string
faker.address.secondaryAddress() // => "Suite 578"
faker.address.secondaryAddress() // 'Apt. 861'

State

Returns a random localized state from this country.

Returns: string

faker.address.state(): string
faker.address.state() // => "Nevada"
faker.address.state() // 'Georgia'

State Abbr

Returns a random localized state's abbreviated name from this country.

Returns: string

faker.address.stateAbbr(): string
faker.address.stateAbbr() // => "NV"
faker.address.stateAbbr() // 'ND'

Street Address

Generates a random localized street address.

Parameters

NameTypeDefaultDescription
useFullAddressbooleanfalse

When true this will generate a full address. Otherwise it will just generate a street address.

Returns: string

faker.address.streetAddress(useFullAddress: boolean = false): string
faker.address.streetAddress() // => "5786 Roselyn Throughway"
faker.address.streetName() // '0917 O'Conner Estates'
faker.address.streetAddress(true) // '3393 Ronny Way Apt. 742'
faker.address.streetAddress(false) // '34830 Erdman Hollow'

Street Name

Generates a random localized street name.

Returns: string

faker.address.streetName(): string
faker.address.streetName() // => "Michale Orchard"
faker.address.streetName() // 'Kulas Roads'

Street Prefix

Returns a random localized street prefix.

Returns: string

faker.address.streetPrefix(): string
faker.address.streetPrefix() // => "b"
fakerGH.address.streetPrefix() // 'Boame'

Street Suffix

Returns a random localized street suffix.

Returns: string

faker.address.streetSuffix(): string
faker.address.streetSuffix() // => "Orchard"
faker.address.streetSuffix() // 'Streets'

Time Zone

Returns a random time zone.

Returns: string

faker.address.timeZone(): string
faker.address.timeZone() // => "Asia/Riyadh"
faker.address.timeZone() // 'Pacific/Guam'

Zip Code

Generates random zip code from specified format. If format is not specified, the locale's zip format is used.

Parameters

NameTypeDefaultDescription
format?string

The optional format used to generate the the zip code. By default, a random format is used from the locale zip formats.

Returns: string

faker.address.zipCode(format?: string): string
faker.address.zipCode() // => "57868-5846"
faker.address.zipCode() // '17839'
faker.address.zipCode('####') // '6925'

Zip Code By State

Generates random zip code from state abbreviation. If state abbreviation is not specified, a random zip code is generated according to the locale's zip format. Only works for locales with postcode_by_state definition. If a locale does not have a postcode_by_state definition, a random zip code is generated according to the locale's zip format.

Parameters

NameTypeDefaultDescription
statestring

The abbreviation of the state to generate the zip code for.

Returns: string

faker.address.zipCodeByState(state: string): string
faker.address.zipCodeByState() // => "57868-5846"
fakerUS.address.zipCodeByState("AK") // '99595'
fakerUS.address.zipCodeByState("??") // '47683-9880'