Skip to main content

Python lib/cli for JSON/YAML schema validation

Project description


YAML/JSON validation library

This framework is a port with a lot of added functionality of the Java version of the framework kwalify that can be found at

The original source code can be found at

The source code of the latest release that has been used can be found at Please note that source code is not the original authors code but a fork/upload of the last release available in Ruby.

The schema this library is based on and extended from:


Create a data file. Json and Yaml formats are both supported.

- foo
- bar

Create a schema file with validation rules.

type: seq
  - type: str

Run validation from cli.

pykwalify -d data.yaml -s schema.yaml


The documentation describes in detail how each keyword and type works and what is possible in each case.

But there is a lot of real world examples that can be found in the test data/files. It shows a lot of examples of how all keywords and types work in practice and in combination with each other.

The files can be found here and show both schema/data combinations that will work and that will fail.

  • tests/files/success/
  • tests/files/fail/
  • tests/files/partial_schemas/

YAML parser

ruamel.yaml is the default YAMl parser installed with pykwalify.

Ruamel.yaml is more supported in the yaml 1.2 spec and is more actively developed.

Depending on how both libraries are developed, this can change in the future in any major update.

UTF-8 and data encoding

If you have problems with unicode values not working properly when running pykwalify on Python 3.6x then try to add this environment variable to your execution:


and it might help to force UTF-8 encoding on all string objects. If this does not work please open up an issue with your schema and data that can be used to track down the problem in the source code.

Project details

python support 3.6, 3.7, 3.8, 3.9
Docs (Latest release)
Docs (Unstable branch)
Gitter (Free Chat) Gitter
Upgrade instructions
Travis (master) Build Status
Travis (unstable) Build Status
Test coverage Coverage Status
Open Hub
License MIT
Copyright Copyright (c) 2013-2017 Johan Andersson
git repo git clone
install stable pip install pykwalify
install dev $ git clone pykwalify
$ cd ./pykwalify
$ virtualenv .venv
$ source .venv/bin/activate
$ pip install -r dev-requirements.txt
$ pip install -e .
required dependencies docopt >= 0.6.2
python-dateutil >= 2.4.2
supported yml parsers ruamel.yaml >= 0.11.0

Project details

Download files

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

Source Distribution

pykwalify-1.8.0.tar.gz (62.5 kB view hashes)

Uploaded source

Built Distribution

pykwalify-1.8.0-py2.py3-none-any.whl (24.9 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page