Newtonsoft.Json.Schema 4.0.2-beta1

Logo Json.NET Schema

NuGet version (Newtonsoft.Json.Schema) Build status

Json.NET Schema is a powerful, complete and easy to use JSON Schema framework for .NET

Validate JSON

JSchema schema = JSchema.Parse(@"{
  'type': 'object',
  'properties': {
    'name': {'type':'string'},
    'roles': {'type': 'array'}
  }
}");

JObject user = JObject.Parse(@"{
  'name': 'Arnie Admin',
  'roles': ['Developer', 'Administrator']
}");

bool valid = user.IsValid(schema);
// true

Generate Schemas

JSchemaGenerator generator = new JSchemaGenerator();
JSchema schema = generator.Generate(typeof(Account));
// {
//   "type": "object",
//   "properties": {
//     "email": { "type": "string", "format": "email" }
//   },
//   "required": [ "email" ]
// }

public class Account
{
    [EmailAddress]
    [JsonProperty("email", Required = Required.Always)]
    public string Email;
}

Validate Deserialization

JSchema schema = JSchema.Parse(@"{
  'type': 'array',
  'item': {'type':'string'}
}");
JsonTextReader reader = new JsonTextReader(new StringReader(@"[
  'Developer',
  'Administrator'
]"));

JSchemaValidatingReader validatingReader = new JSchemaValidatingReader(reader);
validatingReader.Schema = schema;

JsonSerializer serializer = new JsonSerializer();
List<string> roles = serializer.Deserialize<List<string>>(validatingReader);

Showing the top 20 packages that depend on Newtonsoft.Json.Schema.

Packages Downloads
Microsoft.ApplicationInsights.Profiler.Core
Core Library for Microsoft Application Insights Profiler.
14
Microsoft.ApplicationInsights.Profiler.Core
Core Library for Microsoft Application Insights Profiler.
13
Microsoft.ApplicationInsights.Profiler.Core
Core Library for Microsoft Application Insights Profiler.
12

.NET Framework 3.5

.NET Framework 4.0

.NET Framework 4.5

.NET Standard 2.0

.NET Standard 2.1

Version Downloads Last updated
4.0.2-beta2 8 02/27/2025
4.0.2-beta1 13 11/21/2024
4.0.1 12 11/21/2024
3.0.16 10 11/21/2024
3.0.15 11 10/22/2024
3.0.14 12 10/10/2022
3.0.13 12 11/21/2024
3.0.12 11 10/23/2024
3.0.11 12 10/06/2024
3.0.10 13 11/21/2024
3.0.9 9 11/21/2024
3.0.8 13 10/06/2024
3.0.7 10 10/22/2024
3.0.6 13 10/06/2024
3.0.5 11 11/21/2024
3.0.4 10 11/21/2024
3.0.3 11 10/20/2024
3.0.2 11 10/06/2024
3.0.1 10 10/21/2024
2.0.13 9 11/21/2024
2.0.12 9 11/06/2024
2.0.11 10 10/06/2024
2.0.10 10 10/24/2024
2.0.9 9 10/23/2024
2.0.8 12 10/06/2024
2.0.7 11 10/06/2024
2.0.6 13 11/21/2024
2.0.5 9 01/31/2025
2.0.4 12 10/06/2024
2.0.3 9 10/22/2024
2.0.2 10 10/06/2024
2.0.1 11 11/21/2024
1.0.11 11 11/21/2024
1.0.10 9 10/23/2024
1.0.9 9 11/21/2024
1.0.8 10 11/21/2024
1.0.7 11 10/06/2024
1.0.6 11 11/21/2024
1.0.5 10 11/21/2024
1.0.4 10 11/21/2024
1.0.3 10 10/06/2024
1.0.2 11 10/06/2024
1.0.1 11 10/06/2024