Skip to content
Clojure library for validating via JSON Schema - Draft-07 compatible
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

CircleCI License Clojars Project

Clojure JSON Schema Validator

[luposlip/json-schema "0.1.3"]

A Clojure library for JSON validation according to JSON Schema

It's very simple, and supports JSON Schema Draft-07.


Currently this library can only be used to validate data based on a JSON Schema.

It has a single public function, validate that return the validated data when no errors are found. This makes it very easy to incorporate validation in a pipeline (see pseudo example below).

All found errors will cause the function to throw an instance of clojure.lang.ExceptionInfo, which can be inspected with the help of ex-data and the likes.

If you're using Clojure 1.7 or newer, you can convert any Throwable to a map via Throwable->map.

To switch draft versions, simply use the according version notation in the $schema uri (in the root of the JSON document):

{"$schema": "", ...}

{"$schema": "", ...}

{"$schema": "", ...}

JSON and JSON Schema params has to be input as either a JSON encoded string or EDN (map for both or vector for JSON).

Example usage:

(let [schema {:$schema ""
              :id ""
              :type "object"
              :properties {:id {:type "number"
                                :exclusiveMinimum 0}}
              :required [:id]}
      json "{\"id\": 0.001}"] ;; get from url, or anywhere
  (validate schema json)
  (comment do whatever you only wanna do when JSON is valid)

Pseudo-example for pipelining:

(->> huge-seq-of-edn-or-jsonstrings
     (map do-stuff-to-each-doc)
     (map do-even-more-to-each)
     (map (fn [doc]
             (-> "resources/json-schema.json"
                 (cheshire.core/parse-string true))
     (lazily-save-docs-to-disk "/path/to/output-filename.ndjson")

More usage examples can be seen in the tests.


To the maintainers of:, on which this Clojure Library is based.


Copyright © 2019 Henrik Mohr

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at

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

You can’t perform that action at this time.