# URL normalize

`url-normalize` · version 1.0.0 · URLs & IP addresses · free, no key needed

Normalize an absolute http or https URL via WHATWG parse. No DNS, fetch, or security-equivalence claim.

**Use when you need to: url normalize · canonicalize http url · normalize https url.**

## Supported

- url normalize
- canonicalize http url
- normalize https url

## Not supported

- fetch
- dns
- punycode security claim
- http equals https

## Behavior

- Parse with WHATWG URL. Scheme must be http or https (case-insensitive on input). Reject other schemes, relative URLs, and credentials-less parse failures.
- Always applied: WHATWG href serialization (scheme lowercase, host lowercase ASCII/punycode as WHATWG does, default ports 80/443 omitted, empty path becomes /, dot-segment removal).
- strip_fragment default false; if true, drop the fragment.
- Preserve userinfo if present. Do not sort query. Do not claim two URLs are security-equivalent or same-origin beyond the returned string.
- No network.

## Input

- `url` (string, required): min length 1; max length 8192
- `strip_fragment` (boolean, optional)

## Output

- `url` (string, required)

## Limits

- max url bytes: 8192

## Example

Request input:

```json
{
  "url": "HTTP://Example.COM:80/a/../b"
}
```

Response:

```json
{
  "result": {
    "url": "http://example.com/b"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "url-normalize",
  "version": "1.0.0",
  "input": {
    "url": "HTTP://Example.COM:80/a/../b"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/url-normalize/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"url":"HTTP://Example.COM:80/a/../b"}'
```

The machine-readable contract is at [/v1/tools/url-normalize/versions/1.0.0](/v1/tools/url-normalize/versions/1.0.0).

### CLI

```sh
node cli.mjs run url-normalize 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [IPv6 normalize](/tools/ipv6-normalize): Normalize any valid textual IPv6 address directly into its RFC 5952 canonical compressed string.
- [URL query build](/tools/url-query-build): Build a query string or replace an absolute URL query from ordered pairs. No fetching.
- [URL query merge](/tools/url-query-merge): Merge query pairs into an absolute URL. No fetching.
- [URL query parse](/tools/url-query-parse): Parse query pairs and fragment from an absolute URL. Parse only; no fetching.
- [URL resolve](/tools/url-resolve): Resolve a URL against an absolute http(s) base using WHATWG. No fetching. Result must be http(s).
- [IPv4 address classify](/tools/ipv4-address-classify): Classify an IPv4 address against the static IANA IPv4 special-purpose address registry.
