Base62 encoding and decoding in Clojure
a0e328af — Miikka Koskinen 13 days ago
Update home page
pom.xml: Add a link to the homepage
Add a link to Clojars



You can also use your local clone with git send-email.


This library implements Base62 encoding and decoding in Clojure.

#Latest version

#Should I use this?

Only if you need interoperability with an existing system that uses Base62. For new designs, just use (URL-safe) Base64. It's practically as URL-safe as Base62 - strip the padding if that's a problem - and there are performant implementations for almost every language.


There are two functions, encode and decode. encode takes a byte array and returns a base62-encoded string. decode takes a base62-encoded string and returns a byte array.

(require '[clj-base62.core :as base62])

(base62/encode (.getBytes "Hello world!"))
;; "T8dgcjRGuYUueWht"

(String. (base62/decode "T8dgcjRGuYUueWht"))
;; "Hello world!"


It's very slow for long inputs. By long, I mean in the order of 10 kB or bigger. You'll probably want to use Base64 or Base32.


The goal is to be compatible with base-x npm package.


Copyright Miikka Koskinen

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.