[Update]: Since this post Humanizer has gone a very long way. It has also been featured on Scott Hanselman’s blog on his ‘NuGet of the week’ series. Please check out the project homepage on GitHub to see the latest.

Over a year ago I blogged about Humanizer: a micro-framework that helps .Net developers turn strings, type names, enum fields, date fields and numbers into a human friendly format. It has since become a rather popular framework. I am happy to announce the release of Humanizer V0.4 with a fair few useful additions.

The current feature set in a nutshell is:

  • Humanize strings; e.g. "WhenSomethingIsSet".Humanize() -> "When something is set"
  • Humanize enums; e.g. AuthType.AnonymousUser.Humanize() -> "Anonymous user"
  • Humanize dates; e.g. DateTime.Now.AddDays(-1).Humanize() -> "Yesterday"
  • Humanize method accepts an optional casing parameter with support for different casings: Title, Sentence, Lower Case, Upper Case; e.g. "WhenSomethingIsSet".Humanize(LetterCasing.Title) -> "When Something Is Set"
  • Can Inject the date you want to use as basis for date comparison (added in V0.3)
  • Date humanization can be localized (added in V0.3)
  • Dehumanize strings (added in V0.3.1); e.g. "When something is set" -> "WhenSomethingIsSet".Dehumanize()
  • Dehumanize string into enum (added in V0.3.2); e.g. "Anonymous user".Dehumanize<AuthType>() -> AuthType.AnonymousUser
  • Inflector methods courtesy of Inflector.Net (added in V0.4):
    • Pluralize; e.g. "Man".Pluralize() -> "Men" & "string".Pluralize() -> strings
    • Singularize; e.g. "Men".Singularize() -> "Man" & "strings".Singularize() -> string
    • Ordinalize numbers; e.g. 1.Ordinalize() -> "1st", 5.Ordinalize() -> "5th"
    • Ordinalize strings; e.g. "21".Ordinalize() -> "21st"
    • Underscore; e.g. "SomeTitle".Underscore() -> "some_title"
    • Dasherize; e.g. "some_title".Dasherize() -> "some-title"

To learn more about the framework and it’s API please refer to readme.md on github.

Humanizer has a good test coverage and even though it’s a pre-release framework it is quite solid and a lot of teams have been using it in production since V0.2.

Happy Humanizing :)