A .NET library for reading, generating, and validating JSON Schema draft v4+ schemas, with code generation for C# and TypeScript.
NJsonSchema is a .NET library that provides tools for reading, generating, and validating JSON Schema draft v4+ schemas. It solves the problem of ensuring JSON data conforms to a defined structure and facilitates automatic generation of data contracts and client code from schemas or .NET types.
.NET developers working with JSON-based APIs, especially those needing to validate JSON data, generate OpenAPI/Swagger schemas from .NET code, or produce C#/TypeScript client code from JSON Schemas.
Developers choose NJsonSchema for its deep integration with the .NET ecosystem, comprehensive feature set covering schema validation and bidirectional code generation, and its proven reliability as the core engine behind the popular NSwag toolchain.
JSON Schema reader, generator and validator for .NET
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Generates JSON Schemas directly from .NET classes using reflection and standard annotations like [Required] and [Range], ensuring tight coupling with existing codebases without manual schema writing.
Produces C# classes or TypeScript interfaces from JSON Schemas and vice versa, enabling consistent data contracts across full-stack .NET and TypeScript applications, as shown in the detailed examples.
Infers and creates JSON Schemas from sample JSON data via SampleJsonSchemaGenerator, useful for rapid prototyping or reverse-engineering APIs from existing JSON payloads.
Handles schema references ($ref) including relative, URL, and file references, facilitating modular schema design and reuse in complex API specifications.
Generating schemas from .NET types via reflection can be slow for large or nested type hierarchies, impacting startup times or dynamic scenarios in performance-sensitive applications.
Core functionality is split across multiple NuGet packages (e.g., for YAML, C# generation), complicating initial setup and dependency management compared to all-in-one libraries.
Relies on Json.NET and Namotion.Reflection, which may cause versioning issues in projects already using different or conflicting versions of these libraries.
Primarily supports JSON Schema draft v4+, potentially missing newer features from drafts like 2020-12 that are increasingly used in modern API tooling.