Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Build Status Coverage Status

galimatias is a URL parsing and normalization library written in Java.

Design goals

  • Parse URLs as browsers do, optionally enforcing compliance with old standards (i.e. RFC 3986, RFC 2396).
  • Stay as close as possible to WHATWG's URL Standard.
  • Convenient fluent API with immutable URL objects.
  • Interoperable with and
  • Minimal dependencies.


galimatias is not a generic URI parser. It can parse any URI, but only schemes defined in the URL Standard (i.e. http, https, ftp, ws, wss, gopher, file) will be parsed as hierarchical URIs. For example, in git:// you'll be able to extract scheme (i.e. git) and scheme data (i.e. //, but not host (i.e. This is intended. We cannot guarantee that applying a set of generic rules won't break certain kind of URIs, so we do not try with them. I will consider adding further support for other schemes if enough people provides solid use cases and testing. You can check this issue if you are interested.

But, why?

galimatias started out of frustration with and Both of them are good for basic use cases, but severely broken for others:

  • is broken.

  • can parse only RFC 2396 URI syntax. will only parse a URI if it's strictly compliant with RFC 2396. Most URLs found in the wild do not comply with any syntax standard, and RFC 2396 is outdated anyway.

  • is not protocol-aware., and are different entities.

  • Manipulation is a pain. I haven't seen any URL manipulation code using or that is simple and concise.

  • Not IDN ready. Java has IDN support with, but this does not apply to or

Setup with Maven

galimatias is available at Maven Central. Just add to your pom.xml <dependencies> section:


Development snapshots are also available at Sonatype OSS Snapshots repository.

Getting started

Parse a URL

// Parse
String urlString = //...
URL url;
try {
  url = URL.parse(urlString);
} catch (GalimatiasParseException ex) {
  // Do something with non-recoverable parsing error

Convert to

URL url = //... javaURL;
try {
  javaURL = url.toJavaURL();
} catch (MalformedURLException ex) {
  // This can happen if scheme is not http, https, ftp, file or jar.

Convert to

URL url = //... javaURI;
try {
  javaURI = url.toJavaURI();
} catch (URISyntaxException ex) {
  // This will happen in rare cases such as "foo://"

Parse a URL with strict error handling

You can use a strict error handler that will throw an exception on any invalid URL, even if it's a recovarable error.

URLParsingSettings settings = URLParsingSettings.create()
URL url = URL.parse(settings, urlString);


Check out the Javadoc.


Did you find a bug? Report it on GitHub.

Did you write a patch? Send a pull request.

Something else? Email me at


Copyright (c) 2013-2014 Santiago M. Mola

galimatias is released under the terms of the MIT License.


galimatias is a URL parsing and normalization library written in Java.








No packages published