Bebop.JsonSchema 1.1.0

dotnet add package Bebop.JsonSchema --version 1.1.0
                    
NuGet\Install-Package Bebop.JsonSchema -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bebop.JsonSchema" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bebop.JsonSchema" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Bebop.JsonSchema" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bebop.JsonSchema --version 1.1.0
                    
#r "nuget: Bebop.JsonSchema, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bebop.JsonSchema@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bebop.JsonSchema&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Bebop.JsonSchema&version=1.1.0
                    
Install as a Cake Tool

Bebop.JsonSchema

Build and Test Coverage Status NuGet

A high-performance JSON Schema validator for .NET, built on top of System.Text.Json.

Supported JSON Schema Versions

Version Status
Draft 2020-12 ✅ Fully supported (default)
Draft 2019-09 ✅ Fully supported
Draft-07 ❌ Not supported
Draft-06 ❌ Not supported
Draft-04 ❌ Not supported

When no $schema is specified, Draft 2020-12 is assumed. Custom meta-schemas are supported — define your own vocabularies and dialects on top of Draft 2020-12 or 2019-09.

Features

  • Zero-allocation validation path — designed with performance in mind; minimal allocations on the hot path
  • Built on System.Text.Json — no third-party JSON parser dependencies
  • Async-first API — schema creation, preparation, and validation are all async
  • $ref and $dynamicRef resolution — local, HTTP-resolving, and custom schema registries
  • Format validation — built-in validators for email, ipv4, ipv6, uri, uuid, date-time, date, time, duration, and more. In Draft 2020-12 and 2019-09, format is annotation-only by default and becomes an assertion when the format-assertion vocabulary is active.
  • Comprehensive keyword support — type, enum, const, allOf/anyOf/oneOf/not, if/then/else, properties, patternProperties, additionalProperties, items, prefixItems, contains, uniqueItems, unevaluatedProperties, unevaluatedItems, dependentSchemas, dependentRequired, dependencies, and all validation keywords

Targets

Framework Supported
.NET 8
.NET 10

Installation

Install via NuGet:

dotnet add package Bebop.JsonSchema

Or visit the NuGet package page.

Getting Started

Create and validate against a schema

using Bebop.JsonSchema;
using System.Text.Json;

// Define a schema
var schema = await JsonSchema.Create("""
    {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "type": "object",
      "required": ["name", "age"],
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "age":  { "type": "integer", "minimum": 0 }
      }
    }
    """);

// Prepare the schema (resolves $ref, etc.)
await schema.Prepare();

// Validate a JSON document
using var doc = JsonDocument.Parse("""{ "name": "Alice", "age": 30 }""");

var errors = new ErrorCollection();
bool isValid = await schema.Validate(doc, errors);
// isValid == true

Validate from a JsonElement

using var doc = JsonDocument.Parse("""{ "name": "", "age": -1 }""");

var errors = new ErrorCollection();
bool isValid = await schema.Validate(doc.RootElement, errors);
// isValid == false

// Access validation errors
Console.WriteLine($"Found {errors.Count} validation errors:");
foreach (var error in errors)
{
    Console.WriteLine($"  - {error.Message} at {error.Path}");
}

Use a remote-resolving schema registry

If your schema references external schemas via $ref, use a resolving registry that fetches them over HTTP:

var registry = SchemaRegistry.Resolving();
var schema = await JsonSchema.Create(schemaDocument, registry);
await schema.Prepare();

Use a custom schema resolver

Implement ISchemaResolver to control how referenced schemas are loaded (e.g. from a database, embedded resources, or a local file system):

public class MyResolver : ISchemaResolver
{
    public async ValueTask<JsonElement?> Resolve(Uri id)
    {
        // Load the schema JSON by URI and return the root element,
        // or return null if not found.
    }
}

var registry = SchemaRegistry.Custom(new MyResolver());
var schema = await JsonSchema.Create(schemaDocument, registry);
await schema.Prepare();

Schema Registries

Registry Description
SchemaRegistry.Local() In-memory only. No external resolution. Default when none is specified.
SchemaRegistry.Resolving() Fetches remote schemas over HTTP/HTTPS on demand.
SchemaRegistry.Custom(resolver) Delegates resolution to your ISchemaResolver implementation.

Built-in Format Validators

The following format values are validated when the format vocabulary is active:

email · idn-email · ipv4 · ipv6 · uri · uuid · date-time · date · time · duration

Performance

Benchmarks validate a realistic Person object (nested objects, arrays, $ref, $defs, pattern, format, additionalProperties, if/then) against a ~230-line Draft 2020-12 schema. Compared against JsonSchema.Net v8.0.4.

BenchmarkDotNet v0.15.8, Windows 11
Intel Core i7-6560U CPU 2.20GHz (Skylake), 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.103
Method Runtime Mean Allocated
Bebop.JsonSchema .NET 10.0 42.3 μs 31.2 KB
JsonSchema.Net .NET 10.0 109.4 μs 78.0 KB
Bebop.JsonSchema .NET 9.0 40.6 μs 31.5 KB
JsonSchema.Net .NET 9.0 110.6 μs 78.9 KB

~2.6× faster and ~60 % less memory than JsonSchema.Net on the same workload.

Reproduce locally: dotnet run --project Benchmarks.Bebop.JsonSchema -c Release

Project Structure

Bebop.JsonSchema/              # Core library
Tests.Bebop.JsonSchema/        # xUnit test suite (JSON Schema Test Suite)
Benchmarks.Bebop.JsonSchema/   # BenchmarkDotNet benchmarks

Building

dotnet build

Running Tests

dotnet test

Running Benchmarks

dotnet run --project Benchmarks.Bebop.JsonSchema -c Release

License

See LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 1,891 3/12/2026
1.0.0 154 2/21/2026