Skip to main content

url canonicalization library for python and java

Project description

build status

A URL canonicalization (normalization) library for Python and Java.

It currently provides:

  • A URL parser which preserves the input bytes exactly
  • A precanned canonicalization ruleset that tries to match the normalization implicit in the parsing rules used by browsers
  • An alternative URL serialization suitable for sorting and prefix-matching: SSURT.

Status: Stable and in production use for some time. But no API or output stability guarantees yet. There are differences in features between Java and Python versions.



>>> import urlcanon
>>> input_url = "http://///"
>>> parsed_url = urlcanon.parse_url(input_url)
>>> print(parsed_url)
>>> urlcanon.whatwg(parsed_url)
<urlcanon.parse.ParsedUrl object at 0x10eb13a58>
>>> print(parsed_url)
>>> print(parsed_url.ssurt())
>>> rule = urlcanon.MatchRule(ssurt=b'com,example,//:http/bar')
>>> urlcanon.whatwg.rule_applies(rule, b'')
>>> urlcanon.whatwg.rule_applies(rule, b'HTtp:////eXAMple.Com/bar//baz//..///quu')

Python releases are available in PyPI:

pip install urlcanon


String inputUrl = "http://///";
ParsedUrl parsedUrl = ParsedUrl.parseUrl(inputUrl);

// http://///



// "com,example,//:http/bar"

Java releases are available in the Maven Central repository:



  • Copyright (C) 2016-2018 Internet Archive
  • Copyright (C) 2016-2017 National Library of Australia

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this software except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

urlcanon-0.3.1.tar.gz (13.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page