IP Address Utilities

Netmask To Cidr

Converts subnet masks like 255.255.255.0 to CIDR notation (/24). Access via MCP in Cursor or Windsurf for network calculations, or hit the REST endpoint at /v1/ip/netmask-to-cidr. Essential for network automation scripts and IP configuration tools. Returns precise prefix lengths without guesswork.

API Endpoint

GET /v1/ip/netmask-to-cidr

Code Examples

curl "https://tinyfn.io/v1/ip/netmask-to-cidr" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/ip/netmask-to-cidr', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/ip/netmask-to-cidr',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's ip address tools:

{
  "mcpServers": {
    "tinyfn-ip": {
      "url": "https://tinyfn.io/mcp/ip",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I convert netmask 255.255.240.0 to CIDR?

Pass the netmask as a parameter - it returns /20 since 255.255.240.0 represents 20 consecutive 1-bits in binary.

What happens with invalid subnet masks like 255.255.128.255?

The tool validates that subnet masks have consecutive 1-bits followed by consecutive 0-bits, rejecting invalid patterns that aren't proper netmasks.

Can I use this in MCP-enabled editors for network scripting?

Yes, call it directly in Cursor or Claude Code when writing network automation scripts - no need to memorize CIDR conversions or use external calculators.

Does it handle all standard subnet mask formats?

Supports dotted decimal notation (255.255.255.0) and returns CIDR prefixes from /0 to /32 for IPv4 networks.

What's the difference between this and IP-to-CIDR tools?

This specifically converts subnet masks to prefix lengths, while IP-to-CIDR tools typically convert IP addresses with their associated network masks to CIDR blocks.

Try Netmask To Cidr Now

Get your free API key and start using Netmask To Cidr in seconds.

Get Free API Key