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 🙏

© 2026 – Pkg Stats / Ryan Hefner

random-ip-gen

v1.1.2

Published

Generate unique random IPv4 and IPv6 addresses with validation support

Readme

Random IP Generator

Generate unique random IPv4 and IPv6 addresses with validation support.

Features

  • 🎲 Generate unique random IPv4 addresses
  • 🌐 Generate unique random IPv6 addresses
  • ✅ Built-in IP address validation
  • 🔒 Per-instance uniqueness tracking
  • 📦 TypeScript and JavaScript support
  • 🚀 Lightweight and fast

Installation

npm install random-ip-gen

Usage

JavaScript

const { RandomIPv4, RandomIPv6 } = require('random-ip-gen');

// IPv4
const ipv4 = new RandomIPv4();
console.log(ipv4.generate()); // 192.168.1.1
console.log(RandomIPv4.validate('192.168.1.1')); // true

// IPv6
const ipv6 = new RandomIPv6();
console.log(ipv6.generate()); // 2001:0db8:85a3:0000:0000:8a2e:0370:7334
console.log(RandomIPv6.validate('2001:0db8:85a3:0000:0000:8a2e:0370:7334')); // true

TypeScript

import { RandomIPv4, RandomIPv6 } from 'random-ip-gen';

// IPv4
const ipv4 = new RandomIPv4();
const ip: string = ipv4.generate();
const isValid: boolean = RandomIPv4.validate(ip);

// IPv6
const ipv6 = new RandomIPv6();
const ipv6Ip: string = ipv6.generate();
const isValid6: boolean = RandomIPv6.validate(ipv6Ip);

API Reference

RandomIPv4

Constructor

new RandomIPv4()

Methods

  • generate(): string - Generate a unique random IPv4 address
  • generateMultiple(count: number): string[] - Generate multiple unique IPv4 addresses
  • getUniqueCount(): number - Get count of unique IPs generated
  • clear(): void - Clear all generated IPs from memory

Static Methods

  • validate(ip: string): boolean - Validate IPv4 address format

RandomIPv6

Constructor

new RandomIPv6()

Methods

  • generate(): string - Generate a unique random IPv6 address
  • generateMultiple(count: number): string[] - Generate multiple unique IPv6 addresses
  • getUniqueCount(): number - Get count of unique IPs generated
  • clear(): void - Clear all generated IPs from memory

Static Methods

  • validate(ip: string): boolean - Validate IPv6 address format

Examples

// Generate 10 unique IPv4 addresses
const ipv4 = new RandomIPv4();
const ips = ipv4.generateMultiple(10);
console.log(ips); // ['192.168.1.1', '10.0.0.1', ...]

// Validate IP addresses
console.log(RandomIPv4.validate('192.168.1.1')); // true
console.log(RandomIPv4.validate('invalid.ip')); // false

// Per-instance uniqueness
const ipv4a = new RandomIPv4();
const ipv4b = new RandomIPv4();

console.log(ipv4a.generate()); // 192.168.1.1
console.log(ipv4b.generate()); // 192.168.1.1 (different instance, can be same)
console.log(ipv4a.generate()); // 10.0.0.1 (different from previous in same instance)

Development

# Install dependencies
npm install

# Build
npm run build

# Test
npm test

# Development
npm run dev

License

MIT

Contributing

Pull requests are welcome! For major changes, please open an issue first.