hide-ip
v1.0.1
Published
Mask IPv4 and IPv6 addresses with custom masking levels and characters.
Downloads
178
Maintainers
Readme
hide-ip 
Mask IPv4 and IPv6 addresses with custom masking levels and characters. Simple, lightweight, and zero-dependency.
Installation
npm
npm install hide-ipUsage
Mask sensitive IP addresses for logs, UI, or security purposes. Support for both IPv4 and IPv6.
const hideIp = require("hide-ip")
//Basic usage (Default: level 2, maskChar "*")
hideIp("192.0.2.255")
//-> 192.0.*.***
hideIp("2001:db8:85a3:0000:0000:8a2e:0370:7334")
//-> 2001:db8:85a3:0000:0000:8a2e:***:****
//Custom masking level (How many segments to mask from the end)
hideIp("192.0.2.255", {level: 1})
//-> 192.0.2.***
//Custom masking character
hideIp("192.0.2.255", { maskChar: "#" })
//-> 192.168.#.###
//Handling edge cases
hideIp("::1", { level: 1 }) //IPv6 loopback
//-> "::*"
hideIp(null) //Returns original input if not a string
//-> null
hideIp(1234)
//-> 1234API
hideIp(ip, [options])
ip(String): The IPv4 or IPv6 address to mask.options(Object):level(Number): Number of segments to mask starting from the end. Default: 2.maskChar(String): Character used for masking. Default: "*".
License
This software is licensed under the ISC License. Copyright redgold_, 2025.
