DevToolBox

IP to Integer Converter

ブラウザ内で処理

IPv4アドレスと32bit符号なし整数を双方向に変換。すべてブラウザ内で処理します。

How to Use the IP to Integer Converter

Select a direction, enter a dotted IPv4 address or an unsigned integer from 0 through 4294967295, and press Convert. Four octets from 0 through 255 are accepted.

32-bit representation

For a.b.c.d, calculate a × 256³ + b × 256² + c × 256 + d. This concatenates four 8-bit octets in network byte order (big-endian).

Unsigned JavaScript values

Bitwise operators coerce numbers to signed 32-bit integers and can return negative values. This tool uses exact multiplication and division instead.

Databases, logs, and ranges

Numeric addresses simplify indexed range queries, log analysis, and legacy integrations. For dual-stack systems, consider a native IP type that supports IPv6.

IP to Integer Converterの使い方

方向を選び、IPv4または0〜4294967295の整数を入力して変換します。

変換式と背景

各オクテットを8bitとして上位から連結します。逆変換は256の累乗による除算と剰余で各オクテットを復元します。

実務用途

データベースの数値インデックス、ログ解析、IPレンジ判定、整数形式を使うレガシーシステムとの連携に利用できます。IPv6は128bitのため対象外です。

図1: 192.168.1.1が256の累乗で重み付けされ整数3232235777になる仕組み
IPv4オクテットを256の累乗で整数化する仕組み192.168.1.1の4つのオクテットにそれぞれ256の3乗・2乗・1乗・0乗を掛けて合計すると整数3232235777になることを示す図19216811×256³×256²×256¹×256⁰+++32322357774つのオクテットを8bitずつ上位から連結した32bit符号なし整数

IPv4の形式・範囲と負数化の対処 / Fixing IPv4 format, range and signed integer errors

症状 / Symptom原因 / Cause対処 / Fix
IPv4形式エラー
Invalid format
ドット不足・CIDR付き
Missing dots or CIDR suffix
ドット区切り4項目のみ入力
Use four dotted octets
範囲エラー
Range error
オクテットが255超過
Octet above 255
各値を0〜255に修正
Keep each octet in range
整数エラー
Integer error
負数・小数・上限超過
Negative, fraction, or too large
0〜4294967295を使用
Use the supported range
負数になる
Negative result
符号付きビット演算
Signed bitwise operation
算術演算を使用
Use arithmetic

IPv4と整数を往復変換するコード / Code for converting between IPv4 and integers

JavaScript

const ipToInt = ip => ip.split('.').map(Number).reduce((n,o) => n*256+o, 0);
const intToIp = n => [24,16,8,0].map(s => Math.floor(n/2**s)%256).join('.');

Python

def ip_to_int(ip):
    return sum(int(x) << s for x, s in zip(ip.split('.'), (24,16,8,0)))
def int_to_ip(n):
    return '.'.join(str((n >> s) & 255) for s in (24,16,8,0))

Go

v := binary.BigEndian.Uint32(net.ParseIP(ip).To4())
b := make([]byte, 4)
binary.BigEndian.PutUint32(b, v)
ip := net.IP(b).String()

192.168.1.1と整数の変換例 / Converting 192.168.1.1 and other IPv4 values

192.168.1.1 → 3232235777
8.8.8.8 → 134744072
0.0.0.0 → 0
255.255.255.255 → 4294967295
2130706433 → 127.0.0.1

192.168.1.1は16進数で0xC0A80101です。

社内IPを外部送信せず整数変換 / Convert internal IP addresses to integers locally

IP addresses in logs and internal plans can reveal infrastructure. Local JavaScript performs all validation and conversion; no external API receives your data.

ログや社内ネットワークのIPは機密情報になり得ます。本ツールは外部APIを呼ばず、入力をサーバーへ送信しません。

関連ツール・関連ガイド

🔒 すべての処理はブラウザ内で完結し、入力データはサーバーへ送信されません。登録不要・無料。 / All processing runs in your browser; nothing is uploaded. Free, no sign-up. プライバシーポリシー / Privacy Policy

参考資料 / References