Skip to content

decodeIpAddress ​

decodeIpAddress ​

Converts raw IP address bytes back to a human-readable string.
Returns dotted-decimal IPv4 for 4-byte input and colon-separated hex IPv6 for 16-byte input.

Throws on any other length.

ts
function decodeIpAddress(
	bytes: Uint8Array,
): string

Parameters

  • bytes: Uint8Array — Raw IPv4 or IPv6 address bytes.

Returns — The decoded address string.

Examples

ts
decodeIpAddress(Uint8Array.of(127, 0, 0, 1));
// '127.0.0.1'

Released under the MIT License.