Quick Start Guide
April 11, 2026 · View on GitHub
Get started with Humanizer in minutes.
Installation
Install the Humanizer NuGet package:
dotnet add package Humanizer
See Installation for more options.
Basic Examples
Humanize Strings
using Humanizer;
"PascalCaseString".Humanize();
// => "Pascal case string"
"some_property_name".Humanize();
// => "Some property name"
Humanize DateTimes
DateTime.UtcNow.AddHours(-2).Humanize();
// => "2 hours ago"
DateTime.UtcNow.AddDays(1).Humanize();
// => "tomorrow"
Humanize TimeSpans
TimeSpan.FromDays(1).Humanize();
// => "1 day"
TimeSpan.FromMinutes(90).Humanize();
// => "an hour"
Humanize Enums
public enum PaymentStatus
{
PendingApproval,
Approved,
Declined
}
PaymentStatus.PendingApproval.Humanize();
// => "Pending approval"
Pluralization
"person".Pluralize();
// => "people"
"case".ToQuantity(5);
// => "5 cases"
Number Conversions
using System.Globalization;
1234.ToWords();
// => "one thousand two hundred and thirty-four"
1.Ordinalize();
// => "1st"
21.Ordinalize();
// => "21st"
"twelve crore thirty-four lakh fifty-six thousand seven hundred and eighty-nine"
.ToNumber(new CultureInfo("en-IN"));
// => 123456789
123456789.ToWords(new CultureInfo("en-GB"));
// => "one hundred and twenty-three million four hundred and fifty-six thousand seven hundred and eighty-nine"
Fluent Dates
In.January;
// => January 1st of current year
2.Days() + 3.Hours();
// => TimeSpan of 2 days and 3 hours
DateTime.Now + 2.Weeks();
// => DateTime 2 weeks from now
Collections
var items = new[] { "apple", "banana", "cherry" };
items.Humanize();
// => "apple, banana, and cherry"
Truncation
"Long text that needs truncating".Truncate(10);
// => "Long text…"
Common Patterns
Display Property Names in UI
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime DateOfBirth { get; set; }
}
// Generate labels automatically
nameof(Person.FirstName).Humanize();
// => "First name"
nameof(Person.DateOfBirth).Humanize();
// => "Date of birth"
Relative Time Display
var postDate = DateTime.UtcNow.AddHours(-3);
$"Posted {postDate.Humanize()}";
// => "Posted 3 hours ago"
Format Numbers for Display
var count = 1234567;
$"Downloaded {count.ToMetric()} times";
// => "Downloaded 1.23M times"
Pluralize Based on Count
var itemCount = 5;
$"You have {itemCount} {"item".ToQuantity(itemCount)}";
// => "You have 5 items"
var singleItem = 1;
$"You have {singleItem} {"item".ToQuantity(singleItem)}";
// => "You have 1 item"
Next Steps
Explore the documentation for detailed information on each feature: