Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsJul 21, 2026·3 min de lecture

Humanizer — String, Date & Number Manipulation for .NET

Humanizer transforms .NET strings, enums, dates, times, timespans, numbers, and quantities into human-friendly representations, with full localization support for dozens of languages.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Humanizer
Commande d'installation directe
npx -y tokrepo@latest install 26cd05cf-8500-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

Humanizer is a .NET library that turns machine-oriented data into human-readable text. Whether you need to display relative timestamps, pluralize nouns, truncate strings, or convert enums to friendly labels, Humanizer provides a consistent fluent API that keeps your UI code clean and your output natural.

What Humanizer Does

  • Converts PascalCase, camelCase, underscore_case, and kebab-case strings to sentence or title case
  • Displays relative dates and times (e.g., "2 days ago", "in 3 months")
  • Pluralizes and singularizes English nouns with override support
  • Converts numbers to ordinal strings, words, and Roman numerals
  • Truncates strings with configurable strategies (fixed length, word boundary, character)

Architecture Overview

Humanizer is a pure .NET library distributed as a single NuGet package. It targets .NET Standard 2.0 and above, which means it runs on .NET Framework 4.7+, .NET Core, .NET 5-9, Xamarin, and Unity. Localization resources for 40+ languages are bundled as satellite assemblies, and the fluent extension-method API means zero configuration for most use cases.

Self-Hosting & Configuration

  • Install via NuGet: dotnet add package Humanizer
  • No external dependencies or services required
  • Localization is automatic based on Thread.CurrentThread.CurrentUICulture
  • Override pluralization rules by registering custom vocabularies
  • Extend with your own IStringTransformer or ITruncator implementations

Key Features

  • Fluent extension methods on string, DateTime, TimeSpan, int, and enum
  • 40+ localized language packs for date and number humanization
  • Multiple truncation strategies: fixed length, word, character
  • ByteSize helper for human-readable file sizes (e.g., "1.2 GB")
  • Metric prefix support for scientific and engineering notation

Comparison with Similar Tools

  • String.Format / interpolation — built-in but no relative dates, pluralization, or casing transforms
  • NodaTime — advanced date/time modeling but no humanization layer
  • Pluralize.NET — pluralization only; Humanizer covers strings, dates, numbers too
  • FluentDateTime — date arithmetic helpers; does not humanize output
  • SmartFormat.NET — template-based formatting; Humanizer is more extension-method driven

FAQ

Q: Does Humanizer support my language? A: Humanizer ships with localized resources for 40+ languages including Spanish, French, German, Chinese, Japanese, Arabic, and many more.

Q: Can I use Humanizer in Blazor or MAUI apps? A: Yes. Humanizer targets .NET Standard 2.0, so it works in Blazor, MAUI, WPF, WinForms, and any .NET runtime.

Q: How do I add custom pluralization rules? A: Call Vocabularies.Default.AddIrregular("person", "people") or AddUncountable("fish") at startup.

Q: Is Humanizer thread-safe? A: Yes. All extension methods are pure functions. Culture is read from the current thread at call time.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires