Json.NET / Newtonsoft.Json lowercase keys

This post is just a quick tip on how to serialize keys in lowercase using Json.NET. The secret is to use a custom ContractResolver. Definition:

public class LowercaseContractResolver : DefaultContractResolver {
    protected override string ResolvePropertyName(string propertyName) {
        return propertyName.ToLower();


var settings = new JsonSerializerSettings();
settings.ContractResolver = new LowercaseContractResolver();
var json = JsonConvert.SerializeObject(authority, Formatting.Indented, settings);

This will ensure that all keys are in lowercase, even when properties are camelCased etc.

  • Sasha Cherkasoff

    thanks Alexander, this was a time saver!

  • http://www.rswilley.com/ Robert Swilley

    Thanks much! This helped me implement a custom ContractResolver converting snake_case to PascalCase!