JSONGuard
Fast, pythonic JSON schema validation, published on PyPI
- Faster than fastjsonschema
- 116×
- Faster than jsonschema
- 298×
- Lines of core code
- ~250
JSONGuard is a fast, pythonic JSON Schema validator distributed on PyPI. Schemas are defined directly with Python's built-in types and type hints (inspired by sqlmodel), so you skip the boilerplate of formal JSON Schema documents while still getting strict type enforcement, optional fields, and custom validator functions.
The library is roughly 250 lines of optimised code and uses orjson under the hood. Benchmarks place it at ~116× faster than fastjsonschema on basic validation, with depth protection, payload size limits, and either fail-fast or collect-all-errors modes for diagnostics.
What I built
- Pythonic schema definitions
- Schemas are plain Python dicts using built-in types, Union, and Optional. No separate JSON Schema document or DSL to learn.
- Composable custom validators
- Any callable that returns True on valid input works as a validator, enabling regex, range, and domain-specific checks directly inside the schema.
- Performance-first implementation
- Backed by orjson with a tight ~250-line core; benchmarks show ~116× faster basic validation than fastjsonschema and ~298× faster than jsonschema.
- Hardening options
- Configurable max_size_in_bytes, max_depth, and loosely_typed flags protect against oversized payloads and deeply nested DoS attempts.
What I'd do differently
116× is a benchmark of a benchmark. It is measured on the simplest possible schema, and it is the number I am willing to defend because the harness is in the repository and anyone can rerun it — but no one's production schema is the simple one. The honest claim is “substantially faster on hot paths, with the harness published so you can measure your own”, and the next thing this library needs is that benchmark running in a page a reader can press a button on.
It also has a real ceiling. Roughly 250 lines of core covers the schemas it was designed for and nothing beyond them; the moment someone needs `$ref` resolution or conditional subschemas they should reach for a different library. That sentence belongs in the first line of the README rather than buried at the bottom.
- Library Author
- April 2026
- Python, orjson, Type Hints, Pytest, Benchmark tooling
Sundial Lands
Land-buying and cash-offer platform, built solo end to end
Let's get your product off the ground.
A full build, an AI integration, or a second opinion on an architecture that worries you. Thirty minutes on a call is usually enough to tell whether I'm the right person, and I'll say so either way.
“Send a brief” opens an email with the questions already written out.
Before you write
- Status
- Open to work
- My time
- --:-- UTC+3
- Reply
- Within 24h
- First call
- 30 min, free