npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

random-addresses-generator

v1.1.11

Published

random-addresses-generator is a lightweight JavaScript library for generating random and customizable addresses. Perfect for developers needing dummy data for testing, prototyping, or mockups. The package supports various address formats and is designed t

Readme

Random Address Generator

Here is the demo of the npm. https://addressgenerator.io/

Overview

The Random Address Generator package generates realistic random addresses based on country data, with customizable formats and additional fields. The package supports generating random addresses for various countries, and allows you to control various aspects of the address, such as the country, address type, and format.

Installation

To install the package, use npm:

npm install random-addresses-generator

CDN:

<script type="module">
        import { getAddress } from 'https://cdn.jsdelivr.net/npm/[email protected]/src/index.js'; 
        console.log(await getAddress(1));
    </script>

Fields Generated

The address generator can generate the following fields:

  1. buildingNo: The building number or house number (e.g., 123, 456).
  2. buildingName: The name of the building (e.g., "Sunset Tower").
  3. streetNumber: The street number (e.g., 12).
  4. streetName: The name of the street (e.g., "Main St", "Elm Street").
  5. neighborhood: The neighborhood or area (e.g., "Downtown", "Suburbs").
  6. landmark: A nearby landmark or notable feature (e.g., "Near Central Park").
  7. city: The city name (e.g., "New York", "Los Angeles").
  8. state: The state or region name (e.g., "California", "Texas").
  9. zipCode: The postal or zip code (e.g., "10001", "90210").
  10. firstName: The first name of a random person (e.g., "John", "Maria").
  11. lastName: The last name of a random person (e.g., "Doe", "Smith").
  12. phone: A randomly generated phone number (e.g., "+1 (555) 123-4567").
  13. email: A randomly generated email address (e.g., "[email protected]").

Address Type

  • Resedential: Residential addresses (default).
  • Corporate: Corporate addresses such as company headquarters.
  • Industrial: Industrial addresses like factories, warehouses.

Example:

{
  addressType : "Resedential"
}

Addon Fields

You can add custom fields to your address data by using the addon property. This property allows you to inject additional data into the generated address.

Example:

{
  addon: [{
    note: "This is a special note"
  }]
}

This will append a note field to each generated address.

State Selection

You can control which states to generate addresses from by passing an array of state codes. If you don't specify any states, the generator will select from all available states by default.

Example:

{
  states: ["CA", "MN"] // Generates addresses from California and Minnesota only
}

Country Selection

You can specify the country to generate addresses from. The default country is the United States (USA).

Example:

{
  country: "Canada" // Generates addresses from Canada
}

City Selection

You can specify the city to generate addresses from. .

Example:

{
  city: "New York",
  country : "USA" // Generates addresses from New York
}

Address Format

You can specify the format of the generated address using the addressFormat property, which defines the order of the fields. By default, the address format is:

['buildingNo', 'buildingName', 'streetNumber', 'streetName', 'neighborhood', 'landmark', 'city', 'state', 'zipCode', 'firstName', 'lastName', 'phone', 'email']

You can customize the format by passing an array of field names.

Example:

{
  addressFormat: ['firstName', 'lastName', 'city', 'state', 'zipCode']
}

Function Usage

getAddress(count, info)

Generates a specified number of random addresses with the given configuration.

Parameters:

  • count: The number of addresses to generate.
  • info (optional): A configuration object with the following optional properties:
    • country: The country to generate addresses for (default is "United States").
    • addressType: The type of address to generate (options: "Resedential", "Corporate", "Industrial", default is "Resedential").
    • states: An array of state codes (e.g., ["CA", "MN"]), default is ["all"], which generates from all states.
    • addressFormat: A custom format for the address (default is ['buildingNo', 'buildingName', 'streetNumber', 'streetName', 'neighborhood', 'landmark', 'city', 'state', 'zipCode', 'firstName', 'lastName', 'phone', 'email']).
    • addon: Custom fields to be added to each address.
    • format: The format of the output (options: "json", "csv", "text", default is "json").

Example Usage:

  1. Generate 5 Commercial Addresses from the United States:
import { getAddress } from('random-addresses-generator');

const addressData = getAddress(5, {
  country: 'USA', 
  addressType: 'Resedential', 
  format: 'json'
});

console.log(addressData);
  1. Generate 3 addresses from specific states (California and Minnesota):
import { getAddress } from "random-addresses-generator";

const addressData = getAddress(3, {
  country: 'USA', 
  states: ['CA', 'MN'],
  addressFormat: ['firstName', 'lastName', 'streetName', 'city', 'state', 'zipCode'],
  format: 'json'
});

console.log(addressData);
  1. Generate 2 addresses with custom addon field:
import { getAddress } from "random-addresses-generator";

const addressData = getAddress(2, {
  country: 'Canada',
  addressType: 'Corporate',
  addon: [{
    note: "This is a custom note"
  }],
  format: 'json'
});

console.log(addressData);

Supported Countries

The package supports generating random addresses for the following countries:

Available Countries:

  • United States (USA)
  • Canada
  • Germany
  • Argentina
  • Australia
  • Belgium
  • Brazil
  • Canada
  • China
  • Egypt
  • England
  • France
  • Germany
  • Greece
  • India
  • Indonesia
  • United Kingdom
  • Mexico
  • Japan
  • Netherlands
  • New Zealand
  • Nigeria
  • Norway
  • Poland
  • Portugal
  • Russia
  • Saudi Arabia
  • Singapore
  • South Africa
  • South Korea
  • Spain
  • Sweden
  • Switzerland
  • Thailand
  • Turkey
  • UAE
  • Vietnam

What Makes Us Different?

The Random Address Generator stands out by ensuring that the generated addresses are not only random but also relevant and realistic. Each address component, such as the city, zip code, and street name, is carefully matched to ensure consistency and accuracy. This means that the zip code corresponds to the correct city, and the street names are appropriate for the selected country and region. Our generator provides high-quality, believable addresses that can be used for testing, development, and other purposes where realistic data is crucial.