You don't have javascript enabled. Please enable javascript to use this website.

IP Address Sorter

Paste any text or list of IP addresses — IPv4 and IPv6 addresses are extracted, sorted ascending or descending, and ready to copy.
Sort IPs ASC Sort IPs DESC Clear
Copy Copied
More Tools

IP Address Sorter — Numeric Sort for Any IPv4 or IPv6 List

IP address sorter is a browser-based utility that extracts IPv4 (RFC 791) and IPv6 (RFC 4291) addresses from any pasted text and returns them in correct numeric order — ascending or descending. Unlike alphabetical text sorting, which incorrectly ranks 10.0.0.10 before 10.0.0.2, numeric IP sorting compares each octet (IPv4) or hextet (IPv6) as an integer. Input can be a clean list or raw log content containing mixed text — addresses are extracted automatically, deduplicated, and sorted in a single pass.

PropertyDetail
Input formatAny text containing IPv4 or IPv6 addresses — clean list or raw log
IPv4 standardRFC 791 — 32-bit dotted-decimal notation, 0–255 per octet
IPv6 standardRFC 4291 — 128-bit colon-separated hexadecimal; compressed notation supported
Sort methodPer-octet integer comparison (IPv4); lexicographic hextet sort (IPv6)
Output orderIPv4 addresses listed first, IPv6 addresses below
ExecutionClient-side JavaScript — no data transmitted or stored

How to Use the IP Address Sorter

Sort IPv4 and IPv6 addresses from any text in correct numeric order in seconds.

1

Paste Your IP Addresses or Text

Paste a list of IP addresses or any text containing IP addresses — logs, configs, or firewall exports — into the input field.
2

Choose Sort Direction

Click Sort IPs ASC to order from lowest to highest IP value, or Sort IPs DESC to order from highest to lowest.
3

Review Sorted Results

Sorted IPv4 addresses appear first, followed by IPv6 addresses. Duplicate addresses are removed automatically.
4

Copy the Output

Click Copy to copy the sorted list to your clipboard — ready to paste into a document, script, or firewall rule.

Why Alphabetical Sorting Fails for IP Addresses

Standard text sorting treats an IP address as a string of characters. When sorting 10.0.0.2 and 10.0.0.10 alphabetically, the comparison reads character-by-character: the first six characters are identical (10.0.0.), then "2" is compared against "1" — and because "2" has a higher ASCII value than "1", the address 10.0.0.2 is placed after 10.0.0.10. This reverses their correct network order.

Numeric IP sorting resolves this by converting each octet to an integer before comparison. Following RFC 791, each IPv4 address is a 32-bit value expressed as four decimal octets (0–255). The sort compares octet 1, octet 2, octet 3, and octet 4 as integers in sequence. 10.0.0.2 has fourth octet = 2; 10.0.0.10 has fourth octet = 10. Integer comparison correctly places 2 before 10.

IPv6 addresses (RFC 4291) are sorted lexicographically on their colon-separated hexadecimal groups. Full expanded notation and compressed forms — including ::1 (loopback) and 2001:db8::1 (documentation prefix) — are both detected and sorted. Mixed IPv4 and IPv6 input is handled in a single pass; IPv4 results appear first, IPv6 results below.

Command line

How to Sort IP Addresses Without an Online Tool

Command-line options for pre-cleaned lists with one IP per line:

Linux / macOS Terminal (bash/zsh)

# Sort IPv4 addresses numerically
sort -t. -k1,1n -k2,2n -k3,3n -k4,4n ips.txt

# Sort numerically and remove duplicates
sort -t. -k1,1n -k2,2n -k3,3n -k4,4n -u ips.txt

Windows PowerShell

# Sort IPv4 numerically using Version object octet comparison
Get-Content ips.txt | Sort-Object { [System.Version]$_ }

# Sort and remove duplicates
Get-Content ips.txt | Sort-Object { [System.Version]$_ } -Unique

Python 3 Cross-Platform (IPv4 and IPv6)

import ipaddress

with open('ips.txt') as f:
    ips = [line.strip() for line in f if line.strip()]

sorted_ips = sorted(set(ips), key=lambda ip: ipaddress.ip_address(ip))
print('\n'.join(str(ip) for ip in sorted_ips))

The online tool accepts raw text with surrounding content and extracts IP addresses automatically. Command-line options require a pre-cleaned file with one address per line and do not support mixed IPv4 and IPv6 without additional scripting.

Common Uses for IP Address Sorting

Security incident response. A SOC analyst pulls source IP addresses from a SIEM alert — 300 entries in random order from raw firewall logs. Pasting the full log output into the IP Address Sorter instantly organizes the addresses numerically. Contiguous ranges become immediately visible, exposing automated scanning patterns and potential DDoS source blocks that are invisible in unsorted data.

Firewall rule audit. A network engineer exports an access control list from a router — a 500-line config dump mixing IPv4 and IPv6 permit and deny statements. Pasting the full export extracts all addresses, removes duplicates that appear in multiple rules, and sorts them numerically. Gaps in the intended address plan and overlapping ranges become immediately apparent.

Server inventory documentation. A DevOps engineer adds 60 new hosts to a server inventory spreadsheet over three months. The IP address column is out of sequence. Copying the column, sorting it in the tool, and pasting it back takes under 30 seconds — the result is a correctly ordered inventory ready for subnet documentation and DHCP static-assignment planning.


Frequently Asked Questions

What is IP address sorting and why does alphabetical order fail?
IP address sorting arranges IPv4 and IPv6 addresses in correct numeric order, not alphabetical order. Alphabetical sorting misorders addresses — placing 10.0.0.10 before 10.0.0.2 because the character "1" sorts before "2". Numeric IP sorting compares each octet (IPv4) or hextet (IPv6) as an integer, producing the order that matches routing tables, subnet boundaries, and network documentation standards.
How accurate is the IP address sort order?
IPv4 sorting is exact — each address is split into four octets and compared as integers per RFC 791, producing the same ordering as any RFC-compliant network tool. IPv6 addresses are sorted lexicographically on colon-separated hextets, which produces correct ascending and descending network order for consistently formatted addresses. Addresses not conforming to RFC 791 (IPv4) or RFC 4291 (IPv6) are excluded from output automatically.
How many IP addresses can I sort at once?
The tool handles bulk input of any size — paste a single line, a firewall export, or a multi-thousand-line server log. All processing runs client-side in the browser with no server round-trip, so throughput depends on your device's JavaScript engine. Modern browsers handle tens of thousands of IP addresses without visible lag. Raw text with surrounding content is accepted; addresses are extracted automatically before sorting.
Why are some IP addresses missing from the sorted output?
Addresses are excluded if they do not match the IPv4 dotted-decimal pattern (RFC 791: four octets of 0–255) or the IPv6 colon-separated hexadecimal pattern (RFC 4291). Common causes: CIDR notation like 192.168.1.0/24 is a network range, not a single address; IPv4-mapped IPv6 addresses in ::ffff: format are treated as IPv6; and any octet value outside 0–255 is rejected by the validation regex.
Do you store or log the IP addresses I sort?
No. All regex extraction and sort logic runs client-side in JavaScript inside your browser. No input text and no sorted or extracted addresses are transmitted to any server at any point. Closing or refreshing the page clears all data immediately. There is no backend component involved in the sort operation.
What is the difference between IP Address Sorter and IP Address Extractor?
IP Address Extractor scans text and returns every IP address found as a flat, unordered list. IP Address Sorter performs the same extraction step and then orders the results numerically — ascending or descending — with duplicates removed. Use the extractor when you only need to pull IPs from text; use the sorter when you need addresses in network order for firewall rules, log analysis, or subnet documentation.

Related Guides

Guide What Is an IP Address and How Does It Work?
the complete guide to IPv4 and IPv6 addressing, including how 32-bit and 128-bit values are structured, allocated, and compared numerically.
Guide What Is IPv4?
dotted-decimal notation, octet structure per RFC 791, and why per-octet integer comparison is required for correct IP ordering.
Guide What Is IPv6?
128-bit addressing, compressed colon notation per RFC 5952, and how IPv6 hextets are compared during lexicographic sort.