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


CircleCI cljdoc badge Clojars Project bb compatible

A pure Clojure/ClojureScript URI library.

Key features

  • 100% cross-platform .cljc
  • RFC compliant joining of URIs
  • relative URIs as first class citizens

Lambda Island Open Source


uri is part of a growing collection of quality Clojure libraries created and maintained by the fine folks at Gaiwan.

Pay it forward by becoming a backer on our Open Collective, so that we may continue to enjoy a thriving Clojure ecosystem.

You can find an overview of our projects at lambdaisland/open-source.




There are a number of Clojure libraries for working with URI/URLs (see Similar projects below). They all rely to some degree on or This lib provides a pure-Clojure/ClojureScript alternative.

See the announcement blog post


To install, add the following dependency to your project or build file:


lambdaisland/uri {:mvn/version "1.13.95"}


[lambdaisland/uri "1.13.95"]


(require '[lambdaisland.uri :refer [uri join]])

;; uri :: String -> lambdaisland.uri.URI
(uri "//")
;;=> #lambdaisland/uri "//"

;; A URI is a record, use assoc to update specific parts
;; Use `str` if you want the URI back as a string
 (assoc (uri "//")
        :scheme "https"
        :user "arne"
        :password "supersecret"
        :host ""
        :port "3333"
        :path "/hello/world"
        :query "q=5"
        :fragment "section1"))
;;=> ""

;; RFC compliant joining of relative URIs
(join "//" "./~arne/site/" "../foo.png")
;;=> #lambdaisland/uri "//"

;; Arguments to `join` are coerced, you can pass strings,, or any x
;; for which `(str x)` returns a URI string.
(join ( "")  (uri "./~arne/site/") "../foo.png")
;;=> #lambdaisland/uri ""

;; URI implements IFn for keyword based lookup, so it's fully
;; interface-compatible with Clojure maps.
(:path (uri ""))

;; Instances of URI are printed with a #lambdaisland/uri reader tag. To read
;; them back from EDN, use the provided readers.
(require '[clojure.edn :as edn])

 {:readers lambdaisland.uri/edn-readers}
 "#lambdaisland/uri \"\"")

Full API docs are on Cljdoc

Babashka-specific caveats (also applies to SCI)

Instances of URI implement the toString method, so calling (str uri) gives you the URI back as a string. They also implement the IFn interfaces so they are callable the way maps are.

On babashka implementing interfaces or overriding Object methods is not supported. As an alternative to clojure.core/str you can use lambdaisland.uri/uri-str. As an alternative to using the URI as a function, use the keyword as a function, or use clojure.core/get

;; clojure / clojurescript
(str uri) ;; ""
(uri :domain) ;; ""

;; bb
(str uri) ;; "{:scheme "https", :domain "", :path ...}"
(uri :domain) ;; nil

(uri/uri-str uri) ;; ""
(:domain uri) ;; ""
(get uri :domain) ;; ""

Similar projects

  • exploding-fish I was not aware at the time of creating lambdaisland/uri of exploding fish. It is the most mature pure-Clojure URI lib out there. It does not provide ClojureScript support.
  • cemerick/url Cross platform (cljx), Clojure version uses
  • michaelklishin/urly Based on
  • codonnell/uri Based on

Further reading

RFC3986 Uniform Resource Identifier (URI): Generic Syntax

This library implements the algorithm specified in Section 5.2 of that RFC.

It has been tested against this list of test cases compiled by the W3C.


Everyone has a right to submit patches to uri, and thus become a contributor.

Contributors MUST

  • adhere to the LambdaIsland Clojure Style Guide
  • write patches that solve a problem. Start by stating the problem, then supply a minimal solution. *
  • agree to license their contributions as MPL 2.0.
  • not break the contract with downstream consumers. **
  • not break the tests.

Contributors SHOULD

  • update the CHANGELOG and README.
  • add tests for new functionality.

If you submit a pull request that adheres to these rules, then it will almost certainly be merged immediately. However some things may require more consideration. If you add new dependencies, or significantly increase the API surface, then we need to decide if these changes are in line with the project's goals. In this case you can start by writing a pitch, and collecting feedback on it.

* This goes for features too, a feature needs to solve a problem. State the problem it solves, then supply a minimal solution.

** As long as this project has not seen a public release (i.e. is not on Clojars) we may still consider making breaking changes, if there is consensus that the changes are justified.


Copyright © 2017-2021 Arne Brasseur and Contributors

Licensed under the term of the Mozilla Public License 2.0, see LICENSE.


A pure Clojure/ClojureScript URI library







No packages published