Skip to main content
Version: 4.0 (next)

Number and data formatting scenarios

Choose a focused guide​

Choose one operation instead of treating every formatted number as the same kind of string:

TaskFocused guide
Spell cardinal or ordinal numbersNumbers in words and ordinals
Parse a localized number phraseParse number words
Inflect a noun and combine it with a countInflection and quantities
Format or parse storage and ratesByte sizes and rates
Format or parse powers of 1000Metric numerals
Use Roman, compass, multiplier, tuple, or symbol helpersSpecialized formatting utilities

Example​

This program sets English culture and exercises representative formatting calls:

Program.cs
using System.Globalization;
using Humanizer;

var culture = CultureInfo.GetCultureInfo("en-US");
var estonian = CultureInfo.GetCultureInfo("et");
var simplifiedChinese = CultureInfo.GetCultureInfo("zh-CN");
CultureInfo.CurrentCulture = culture;
CultureInfo.CurrentUICulture = culture;

Console.WriteLine($"Words: {42.ToWords(culture)}");
Console.WriteLine($"Ordinal words: {21.ToOrdinalWords(culture)}");
Console.WriteLine($"Long ordinal: {2_147_483_651L.Ordinalize(culture)}");
Console.WriteLine($"Indian scale: {1_000_000_000L.ToIndianWords(IndianScaleStyle.CroreBased)}");
Console.WriteLine($"Fraction: {1.25m.Fractionalize(5, 0m)}");
Console.WriteLine($"Financial: {10L.ToChineseFinancialCharacters(simplifiedChinese)}");
Console.WriteLine($"Estonian scale: {1_000_000_000_000_000_000L.ToWords(estonian)}");
Console.WriteLine($"Long max: {long.MaxValue.ToWords(estonian)}");
Console.WriteLine($"Long min: {long.MinValue.ToWords(estonian)}");
Console.WriteLine($"Roman: {14.ToRoman()}");
Output
Words: forty-two
Ordinal words: twenty-first
Long ordinal: 2147483651st
Indian scale: one hundred crore
Fraction: 1 1/4
Financial: 壹拾
Estonian scale: triljon
Long max: üheksa triljonit kakssada kakskümmend kolm biljardit kolmsada seitsekümmend kaks biljonit kolmkümmend kuus miljardit kaheksasada viiskümmend neli miljonit seitsesada seitsekümmend viis tuhat kaheksasada seitse
Long min: miinus üheksa triljonit kakssada kakskümmend kolm biljardit kolmsada seitsekümmend kaks biljonit kolmkümmend kuus miljardit kaheksasada viiskümmend neli miljonit seitsesada seitsekümmend viis tuhat kaheksasada kaheksa
Roman: XIV

Focused guides separate the typed model, parsing contract, localization behavior, and failure modes. Pass CultureInfo directly where an overload permits it; scope both ambient cultures for APIs without a culture argument.

Keep the typed number​

Do not persist humanized number text as the numeric source of truth. ByteSize uses binary multiples, metric numerals use decimal powers, number-word parsing has locale-specific grammar, and Roman numerals have a strict range. Keep the typed value and choose a parser only for an input format the application explicitly accepts.