NoJsonSchema
Generate C# types and a zero-dependency UTF-8 JSON parser/emitter from JSON Schema.
NoJsonSchema reads a JSON Schema file and generates C# classes with custom serialization code that has zero third-party dependencies, making it safe for Unity, native AOT, and trimmed .NET apps.
NoJsonSchema is a tool for C# developers that reads a JSON Schema document and generates C# classes along with code to convert those classes to and from JSON. The main selling point is that the generated code has no third-party dependencies and works in environments where standard JSON libraries struggle, such as Unity games, applications compiled to native machine code, and trimmed deployments.
A JSON Schema is a structured description of what a JSON document should look like, specifying which fields exist, what types they are, and which are required. NoJsonSchema takes that description and produces C# class definitions that match it, plus a serializer (which turns objects into JSON text) and a deserializer (which parses JSON text back into objects). Both are custom-built using low-level byte operations, which makes them somewhat faster than the built-in .NET JSON library.
The generated files use only the standard .NET base class library, nothing from NuGet or any external package. This matters for Unity / IL2CPP (Unity's ahead-of-time compiler), native AOT compilation, and apps that use aggressive code trimming, where reflection-based JSON libraries often cause problems.
There are three ways to use the tool. The first is a source generator: you add a NuGet package to your project, list your schema files in the project configuration, and the types are generated automatically at build time. The second is a command-line tool you can call as part of your own scripts or build pipeline. The third is a library API for integrating the generator into your own tooling.
The tool supports JSON Schema Draft 2020-12, Draft-07, and OpenAPI 3.x documents. It can read schema files from local paths or directly from HTTP URLs. The project is released under the MIT License.
Where it fits
- Generate dependency-free C# classes from a JSON Schema for Unity games compiled with IL2CPP.
- Add a NuGet source generator so C# types are auto-generated from schema files at build time.
- Use the CLI tool to generate C# serialization code as part of a CI/CD build pipeline.
- Parse OpenAPI 3.x schemas into C# types for apps using native AOT or aggressive code trimming.