Feed it a YAML file, a config snippet, or a firewall ruleset and ipsort reorders the CIDRs and hands everything else back untouched.
annotations: whitelist: >- 192.168.1.0/24, 10.99.0.0/16, 10.0.0.0/8, 172.16.5.0/24 spec: host: app.example.com
annotations: whitelist: >- 10.0.0.0/8, 10.99.0.0/16, 172.16.5.0/24, 192.168.1.0/24 spec: host: app.example.com
A few highlights (see the full feature list on GitHub).
Sort IPs across multiple lines as one pool. Useful for multi-line annotation values.
Merge adjacent CIDRs into their minimal supernet.
10.0.0.0/25 + 10.0.0.128/25 → 10.0.0.0/24
Deduplicate by normalized CIDR. First occurrence wins.
Exit 0 if already sorted. Combine with any flag for CI enforcement.
YAML list markers, JSON brackets, inline keys are all preserved exactly.
Mixed input supported. IPv4 sorts first by default;
--ipv6-first
reverses this.
Download a pre-built binary for your platform from the releases page, or build from source. Shell completions and a manpage are included. See the README for full installation instructions.