ForHosting KIT · Developer Utilities

IP address version detector

This IP address version detector checks whether a string is a complete IPv4 address, a complete IPv6 address, or neither.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Valid input returns the detected version and a stable canonical representation that is easier to compare, store, and review. Invalid address text returns a specific reason, such as an out-of-range IPv4 octet, an illegal leading zero, too many IPv6 groups, or incorrect double-colon compression. The parser is deterministic, uses no network lookup, and treats addresses strictly rather than guessing what incomplete or decorated input was intended to mean.

Identify IPv4 and IPv6 syntax precisely

IPv4 and IPv6 represent addresses in very different textual forms, and checking only for a period or colon is not enough to validate either one. This detector parses the complete string against the structural rules for both versions. IPv4 must have exactly four decimal octets separated by periods. Every octet must be between 0 and 255, must contain digits only, and must not use a leading zero. IPv6 uses eight hexadecimal groups, with colons between them, and can shorten one run of zero groups with a double colon. An IPv6 address may also end with an embedded dotted-decimal IPv4 address when the overall group count remains correct. The output says IPv4 or IPv6 only after the entire value passes validation. A value that merely resembles an address is classified as neither and includes a reason that identifies the failed rule. This makes the result appropriate for form validation, configuration checks, import cleanup, and automated tests where a loose guess could silently accept bad data.

Use canonical output for comparisons and storage

A valid IP address can have more than one textual spelling, especially in IPv6. Uppercase and lowercase hexadecimal digits represent the same values, leading zeros inside a group do not change the address, and a run of zero groups can be compressed. The canonical IPv6 result uses lowercase hexadecimal, removes unnecessary leading zeros, and compresses the longest run of two or more zero groups. If equally long runs exist, it compresses the first one. Embedded dotted-decimal IPv4 components are converted to their equivalent hexadecimal groups so the response always has one consistent IPv6 form. IPv4 is returned as four ordinary decimal octets. These normalization rules let systems compare canonical strings without confusing two spellings of the same address for two different endpoints. They are also useful when preparing logs, deduplicating configuration values, building test snapshots, or presenting an address for human review. Canonicalization does not perform DNS, geolocation, subnet analysis, or reachability testing; it changes representation only, without changing the numeric address.

Interpret rejection reasons and strict boundaries

When address text is invalid, the response reports version as neither and explains why it was rejected. Common IPv4 failures include a missing octet, a component above 255, non-decimal characters, or a leading zero that could be interpreted differently by older software. Common IPv6 failures include a group longer than four hexadecimal digits, the wrong number of expanded groups, more than one double colon, or compression that replaces no group at all. Brackets used in URL authority syntax, CIDR prefix lengths, port numbers, and zone identifiers are intentionally outside this input contract. Remove those decorations and submit only the address itself. This strict boundary keeps validation predictable across browsers, servers, and programming languages whose convenience parsers may accept different historical forms. A missing or non-string address is a request-contract error, while a supplied string with invalid address syntax is a normal detection result with a rejection reason. The algorithm has bounded work, no external state, and no network call, so repeated requests always agree. API requests cost $0.002, and the browser version can run locally.

Validate configuration input

Reject malformed host addresses before they reach firewall rules, service settings, or deployment templates.

Normalize an address inventory

Convert equivalent IPv6 spellings to one canonical representation before comparing or deduplicating records.

Explain failed form entries

Show a useful syntax reason when a user enters something that is not a complete IPv4 or IPv6 address.

Does the detector contact the address?

No. It validates and formats address text locally without DNS, network probes, geolocation, or reputation lookups.

Are CIDR prefixes accepted?

No. Submit only the address. A suffix such as /24 or /64 is network-prefix notation and is outside this detector's input contract.

Why are IPv4 octets with leading zeros rejected?

Leading zeros have historically created decimal-versus-octal ambiguity. Strict dotted-decimal input avoids inconsistent interpretation.

How is an IPv6 address canonicalized?

Hexadecimal letters become lowercase, group-leading zeros are removed, and the longest eligible zero run is compressed with a double colon.

Can I submit an IPv6 URL in brackets with a port?

No. Remove the brackets and port first, because they belong to URL or endpoint syntax rather than to the IP address itself.

What does an API request cost?

Each API request costs $0.002. The deterministic browser tool can also run locally on the page.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/dev/ip-version-detect

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/dev/ip-version-detect \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"address":"2001:0db8:0000:0000:0000:ff00:0042:8329"}'
{
  "address": "2001:0db8:0000:0000:0000:ff00:0042:8329"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "dev.ip_version_detect",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →