CodeMD repository analysis · example report

Humanizr/Humanizer

An analysis of github.com/Humanizr/Humanizer as it was on 2026-11-13.

2409files analyzed
12features
55quality signals
0security findings

Overview

What the repository is and how it is built, written by AI from the analysis.

Humanizer

Summary

Humanizer is a .NET library that turns strings, enums, dates, times, durations, numbers, quantities, byte sizes and collections into human-friendly text. It is released under the MIT license and distributed through NuGet. A documentation site at humanizr.net/docs covers getting started, common scenarios, upgrade guides and an API reference. The current documentation describes the v4 previews, with migration guidance from earlier versions.

Key features

  • String humanizing and casing: Turns PascalCase, underscore_case and similar strings into readable text. Converts between casings such as camelCase, kebab-case, Title Case and underscore_case.
  • Pluralization and singularization: Includes TryPluralize and TrySingularize, which use a culture's CLDR cardinal noun forms.
  • Dates, times and durations: Produces human-friendly phrases, including case-aware duration phrases (HumanizeWithCase) for locales with verified support.
  • Numbers to words and back: Converts numbers and ordinals to words across many locales, and parses forms such as "forty-two" back into numbers.
  • Roman and metric numerals: Converts integers to and from Roman numerals, and numbers to and from metric notation such as 1000 to "1k".
  • Byte sizes and rates: Formats, parses and composes byte sizes and rates. Legacy, decimal SI and binary IEC unit systems are available.
  • Enums and collections: Makes enum values readable and parses the text back. Formats collections as human-friendly text.
  • Localization: Gives locale-aware output for many cultures. Where a locale lacks verified support, it throws NotSupportedException instead of falling back to English.
  • Chinese financial numerals: Converts numbers to Chinese financial characters for zh-Hans and zh-Hant.

Typical use cases

  • Showing readable labels in user interfaces from code identifiers or enum values.
  • Displaying relative times, durations and quantities in the user's own language.
  • Formatting file sizes and transfer rates.
  • Spelling out numbers and ordinals, or reading numbers typed as words.
  • Generating correct singular and plural noun forms for counts.
  • Migrating an application from Humanizer v2 or v3 to the current version with the help of the bundled analyzer.

Architecture

The main library lives in src/Humanizer, with xUnit tests in tests/Humanizer.Tests.

src/Humanizer.Analyzers contains a Roslyn analyzer and code fix provider that helps with migration. It detects the old sub-namespaces (such as Humanizer.Bytes and Humanizer.Localisation) that were consolidated into the root Humanizer namespace, and it offers automatic fixes. It also helps with words-to-number API changes such as ToNumber now returning long. Fix All works across a document, project or solution. Analyzer assets are shipped per Roslyn version and are selected automatically by modern SDK and IDE hosts. The same package also carries the generated locale data, so there is no separate locale or analyzer package to manage.

For performance, the implementation uses source-generated regex, FrozenDictionary and SearchValues to reduce allocations on modern .NET. BenchmarkDotNet suites in src/Benchmarks cover these areas and run on .NET 10 and .NET 11. A manual GitHub Actions workflow compares a baseline NuGet version with the current source.

Contributions are welcome. Read the contribution guide first, and report bugs or request features through GitHub issues.

Features

12 features found in the code and documentation.

String humanizing and casing

Turns PascalCase, underscore_case and similar strings into readable text and converts between casings such as camelCase, kebab-case, Title Case and underscore_case.

Pluralization and singularization

Pluralizes and singularizes words, with TryPluralize and TrySingularize that use a culture's CLDR cardinal noun forms.

Date, time and duration humanizing

Turns dates, times and durations into human-friendly phrases, including case-aware duration phrases for locales with verified support.

Numbers to words and back

Converts numbers to words and ordinals across many locales, and parses word forms such as "forty-two" back into numbers.

Roman and metric numerals

Converts integers to and from Roman numerals, and numbers to and from metric notation such as 1000 to "1k".

Byte sizes and rates

Formats, parses and composes byte sizes and rates, with legacy, decimal SI and binary IEC unit systems.

Enum humanizing

Turns enum values into readable text and parses that text back into enum values.

Collection humanizing

Formats collections of items as human-friendly text.

Localization across cultures

Produces locale-aware output for many cultures, and throws NotSupportedException instead of falling back to English where a locale lacks verified support.

Chinese financial numerals

Converts numbers to Chinese financial characters for zh-Hans and zh-Hant.

Migration analyzer and code fixes

A Roslyn analyzer flags old Humanizer namespaces and words-to-number API changes, and offers automatic fixes across a document, project or solution.

Performance-optimized implementation

Uses source-generated regex, FrozenDictionary and SearchValues for faster, lower-allocation humanizing on modern .NET.

Static quality signals

Possible problems found without running the code.

55signals found
11high severity
17confirmed by the analysis
38need a human to check
KindSignalWhereSeverity
Possible bugsOS command execution API used
`subprocess.run` executes an operating-system command.
.agents/skills/add-locale-batch/scripts/locale_batch_status.py:19medium
Possible bugsFunction has no error handling
`unresolved_threads` has no try/except, logging call, or raised/returned error response.
.agents/skills/add-locale-batch/scripts/locale_batch_status.py:44medium
Possible bugsFunction has no error handling
`checks_state` has no try/except, logging call, or raised/returned error response.
.agents/skills/add-locale-batch/scripts/locale_batch_status.py:64medium
Possible bugsFunction has no error handling
`refresh_entry` has no try/except, logging call, or raised/returned error response.
.agents/skills/add-locale-batch/scripts/locale_batch_status.py:82medium
Possible bugsFunction has no error handling
`main` has no try/except, logging call, or raised/returned error response.
.agents/skills/add-locale-batch/scripts/locale_batch_status.py:111medium
StructureImport may be unused
`annotations` is imported but not referenced in this file.
.agents/skills/add-locale-batch/scripts/locale_batch_status.py:4low
StructureFile has parsed code but no static links
`Benchmarks/VocabularyBenchmarks.cs` contains 2 parsed code areas but none are connected in the static callgraph.
Benchmarks/VocabularyBenchmarks.cslow
StructureFile has parsed code but no static links
`Humanizer.SourceGenerators/Common/EngineContractModels.cs` contains 3 parsed code areas but none are connected in the static callgraph.
Humanizer.SourceGenerators/Common/EngineContractModels.cslow
StructureFile has parsed code but no static links
`Humanizer.SourceGenerators/Common/LocaleCoverageInput.cs` contains 6 parsed code areas but none are connected in the static callgraph.
Humanizer.SourceGenerators/Common/LocaleCoverageInput.cslow
StructureFile has parsed code but no static links
`Humanizer.SourceGenerators/Common/LocalePhraseModels.cs` contains 15 parsed code areas but none are connected in the static callgraph.
Humanizer.SourceGenerators/Common/LocalePhraseModels.cslow
StructureFile has parsed code but no static links
`Humanizer.SourceGenerators/Common/ProfileDefinitions.cs` contains 11 parsed code areas but none are connected in the static callgraph.
Humanizer.SourceGenerators/Common/ProfileDefinitions.cslow
StructureFile has parsed code but no static links
`Humanizer.SourceGenerators/Generators/ProfileCatalogs/HeadingTableCatalogInput.cs` contains 2 parsed code areas but none are connected in the static callgraph.
Humanizer.SourceGenerators/Generators/ProfileCatalogs/HeadingTableCatalogInput.cslow
StructureFile has parsed code but no static links
`Humanizer.SourceGenerators/Generators/ProfileCatalogs/MetricScaleWordCatalogInput.cs` contains 3 parsed code areas but none are connected in the static callgraph.
Humanizer.SourceGenerators/Generators/ProfileCatalogs/MetricScaleWordCatalogInput.cslow
Call graphCircular call relationship
3 functions participate in a static call cycle.
Humanizer.SourceGenerators/Common/CanonicalLocaleAuthoring.cs:867medium
Call graphCircular call relationship
2 functions participate in a static call cycle.
Humanizer.SourceGenerators/Common/LocaleYamlCatalog.cs:928medium
Call graphCircular call relationship
6 functions participate in a static call cycle.
Humanizer.SourceGenerators/Common/LocaleYamlCatalog.cs:1409medium
Call graphCircular call relationship
3 functions participate in a static call cycle.
Humanizer/Inflections/LocalizedInflectionCatalog.cs:93medium
Call graphCircular call relationship
2 functions participate in a static call cycle.
Humanizer/Localisation/NumberToWords/HyphenatedOrdinalNumberToWordsConverter.cs:84medium
Across filesMissing internal call target
`TimeOnlyToClockNotationConverterBenchmarks.EsClockNotationConverter` calls `Humanizer.ITimeOnlyToClockNotationConverter.Convert`, but the target was not found in the parsed function index.
Benchmarks/TimeOnlyToClockNotationConverterBenchmarks.cs:10high
Across filesMissing internal call target
`TimeOnlyToClockNotationConverterBenchmarks.EsClockNotationConverter` calls `Humanizer.PhraseClockNotationConverter.Convert`, but the target was not found in the parsed function index.
Benchmarks/TimeOnlyToClockNotationConverterBenchmarks.cs:10high
Across filesMissing internal call target
`TimeOnlyToClockNotationConverterBenchmarks.BrazilianPortugueseClockNotationConverter` calls `Humanizer.ITimeOnlyToClockNotationConverter.Convert`, but the target was not found in the parsed function index.
Benchmarks/TimeOnlyToClockNotationConverterBenchmarks.cs:18high
Across filesMissing internal call target
`TimeOnlyToClockNotationConverterBenchmarks.BrazilianPortugueseClockNotationConverter` calls `Humanizer.PhraseClockNotationConverter.Convert`, but the target was not found in the parsed function index.
Benchmarks/TimeOnlyToClockNotationConverterBenchmarks.cs:18high
Across filesMissing internal call target
`TimeOnlyToClockNotationConverterBenchmarks.FrClockNotationConverter` calls `Humanizer.ITimeOnlyToClockNotationConverter.Convert`, but the target was not found in the parsed function index.
Benchmarks/TimeOnlyToClockNotationConverterBenchmarks.cs:26high
Across filesMissing internal call target
`TimeOnlyToClockNotationConverterBenchmarks.FrClockNotationConverter` calls `Humanizer.PhraseClockNotationConverter.Convert`, but the target was not found in the parsed function index.
Benchmarks/TimeOnlyToClockNotationConverterBenchmarks.cs:26high
Across filesMissing internal call target
`TimeOnlyToClockNotationConverterBenchmarks.LbClockNotationConverter` calls `Humanizer.ITimeOnlyToClockNotationConverter.Convert`, but the target was not found in the parsed function index.
Benchmarks/TimeOnlyToClockNotationConverterBenchmarks.cs:34high
Across filesMissing internal call target
`TimeOnlyToClockNotationConverterBenchmarks.LbClockNotationConverter` calls `Humanizer.PhraseClockNotationConverter.Convert`, but the target was not found in the parsed function index.
Benchmarks/TimeOnlyToClockNotationConverterBenchmarks.cs:34high

A sample of the highest-ranked signals. These come from static analysis: they are leads to review, not confirmed bugs.

Unused functions

Functions nothing in the repository calls.

No unused functions were found.

Recent changes

What changed in the last 30 days, in plain language.

Summary of Humanizer changes (evidence limited to the first three of 10 commits; the payload was cut off, so the remaining 7 commits and 5-author totals are not covered).

  1. 66e5c56 – "Add Bits(double) extension for fractional bit values (#1953)" by Wallor, 2026-10-03. This is the one user-facing feature in the set. ByteSizeExtensions.Bits(this double input) was added in src/Humanizer/Bytes/ByteSizeExtensions.cs. It calls ByteSize.FromBytes(input / ByteSize.BitsInByte), so fractional bits are kept in ByteSize.Bytes, while ByteSize.Bits rounds up to a whole bit. For example, 2.5 bits gives 0.3125 bytes and a Bits value of 3. The commit adds a DoubleBits unit test that checks exactly this. It updates the public API approval snapshots for DotNet8_0, DotNet10_0, DotNet11_0 and Net4_8. It adds the method to the generated API docs page (website/docs/api/Humanizer.ByteSizeExtensions.md). It also updates the source hash for ByteSizeExtensions.cs in website/docs/contributing/locale-yaml-reference.mdx. Impact: it is additive, so existing callers are unaffected.
  1. 755626e – "fix(truncation): treat any whitespace as a word boundary (#1969)" by Dylan Pulver, 2026-10-03. This is a bug fix in DynamicLengthAndPreserveWordsTruncator. When the cutoff falls mid-word, the truncator used to backtrack with value.LastIndexOf(' ', ...), so only a plain space counted as a boundary. It now uses a new helper, LastIndexOfWhiteSpace, which scans backward with char.IsWhiteSpace. That matches the existing backward scan in TruncateFromLeft. Tabs, newlines, CRLF and non-breaking spaces now count as boundaries. For example, "221B Baker Street\nLondon NW1 6XE" truncated to 20 characters gives "221B Baker Street…". A new theory test with six inline cases covers this. The analysis reports a low-risk, localized change with no callers or impacted files in the callgraph data.
  1. ad458c4 – "fix(docs): preserve API identity and content with tool 1.2.6 (#1975)" by dependabot[bot], 2026-10-03. This is docs tooling work. The defaultdocumentation.console tool was bumped from 1.2.5 to 1.2.6 in .config/dotnet-tools.json. ByteRate.CompareTo(object?) in src/Humanizer/Bytes/ByteRate.cs had /// <inheritdoc /> replaced with explicit summary, param, returns and exception docs. ApiAccessRecord in tools/docs/api-access.cs gained a MethodReturnType property, filled from signature.ReturnType. In tools/docs/api-reference.ps1, the temporary-XML alias workaround New-DefaultDocumentationApiInput was removed. The script now dot-sources api-xml-input.ps1 and adds Resolve-ApiConversionMethodId, which resolves generated IDs for conversion-named methods (op_Implicit, op_Explicit, op_CheckedExplicit) against assembly-derived records. The diff shown for this commit is truncated, so the full file list (7 files) is not visible.

Overall: one small additive public API (Bits(double)), one truncation correctness fix, and one dependency-driven docs-generation update. All three landed on 2026-10-03.

Ask about this repository

An example question, answered from the code.

What does this project do and how is it organised?

Question Summary

The user asked what this project does and how its code and repository are organised.

Direct Answer

  • [UNKNOWN] No source snippet states the project's purpose directly. The only description is in STORED GENERATED CONTEXT, which is derived and not source truth. It says the project is Humanizer, a .NET library that turns strings, enums, dates, times, durations, numbers, quantities, byte sizes and collections into human-friendly text.
  • [MARKUP] The code shown supports a localisation and inflection focus. It includes an inflection engine and bundle (Humanizer/Inflections/InflectionEngine.cs, Humanizer/Inflections/InflectionBundle.Text.cs, Humanizer/Inflections/LocalizedInflectionCatalog.cs). It also includes localisation code (Humanizer/Localisation/EifelerRule.cs) and quantity formatting (Humanizer/ToQuantityExtensions.cs).
  • [MARKUP]/[GRAPH] The repository appears to contain several parts: a main library (Humanizer/, also shown as src/Humanizer/...), a source generator (Humanizer.SourceGenerators/, namespace Humanizer.SourceGenerators), Roslyn analyzers (src/Humanizer.Analyzers/README.md, Humanizer.Analyzers.NamespaceMigrationCodeFixProvider), and tests run via dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj (AGENTS.md:29).
  • [UNKNOWN] The evidence does not give the full directory tree, the build configuration or the public API surface.

Detailed Explanation

What the project does
  • [UNKNOWN] The purpose rests on STORED GENERATED CONTEXT only. It describes Humanizer as an MIT-licensed .NET library, a v4 preview following a v3 baseline, with a documentation site. I did not corroborate any of this in code.
  • [MARKUP] InflectionBundle.Text.Project (Humanizer/Inflections/InflectionBundle.Text.cs:5-46) takes input, output, a CaseProjection and an InflectionStatus, and returns an InflectionResult:
  • It returns Unsupported with the original input if output is empty or not well-formed UTF-16.
  • If casing == InflectionCasing.LowerTitleUpper and the projection is Title, it calls TryProjectUpper(..., firstOnly: true, ...). If the projection is Upper, it calls TryProjectUpper(..., firstOnly: false, ...). A failure in either call returns Unsupported.
  • Otherwise projected = output.
  • It then requires IsScriptEligible(projected, allowNonLetters: true), or returns Unsupported.
  • Finally it returns Invariant if the projected string equals the input (ordinal comparison). Otherwise it returns the supplied status with the projected text.
  • [GRAPH] Callers of Project are InflectionBundle.Inflect, InflectReverseProductive and TryExact. Its callees are IsScriptEligible, IsWellFormedUtf16 and TryProjectUpper.
  • [MARKUP] LocalizedInflectionCatalog.Inflect (Humanizer/Inflections/LocalizedInflectionCatalog.cs:48-59) takes a CultureInfo, direction, productive flag, plural category and quantity. If TryResolveBundle succeeds for the culture, it delegates to bundle.Inflect(...). Otherwise it returns a result with the resolution status and the original input.
  • [MARKUP] InflectionEngine.TryExact (Humanizer/Inflections/InflectionEngine.cs:530-632) does a binary search over forward or reverse entries, depending on direction. For LowerTitleUpper casing it compares case-insensitively. For Mixed projection, a match that is not an exact ordinal match gives Unknown. The snippet is truncated, so the rest is not shown.
  • [GRAPH] Other callgraph nodes are low-confidence [SEMANTIC] candidates. They suggest number-to-words and words-to-number converters (SuffixScaleWordsToNumberConverter.TryAdd), ByteSize, collection formatters, truncators and ToQuantityExtensions.ConcatWithSpace. These are shown only as names and edges, not bodies.
How it is organised
  • [MARKUP] The main library lives under Humanizer/. Paths seen include Inflections/, Localisation/ and Localisation/WordsToNumber/. Some source-text paths use src/Humanizer/....
  • [MARKUP] Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogEmission.cs is a source generator. [GRAPH] HumanizerSourceGenerator.CompareInflectionKeys is a caller of InflectionUnicodeData.CompareSimpleCase, which suggests the generator shares inflection key comparison logic with the runtime.
  • [MARKUP] src/Humanizer.Analyzers/README.md:40 mentions a "Fix All in Project" quick action. [GRAPH] Humanizer.Analyzers.NamespaceMigrationCodeFixProvider.GetReplacementName calls StringHumanizeExtensions.Concat.
  • [MARKUP] AGENTS.md:29 says tests run with dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj for net8.0, net10.0 and net11.0 on all platforms. net48 is run only on Windows.
  • [UNKNOWN] STORED GENERATED CONTEXT, which I could not verify in source, also lists src/Benchmarks, tools/Humanizer.UnicodeDataGenerator and website/docs.
Gaps
  • [UNKNOWN] The evidence has no top-level README text, no project files and no full file listing. The public API and the build setup are not established.

Security review

An AI review of how outside input reaches risky operations.

No exploitable findings.

Humanizer is a pure .NET formatting library. Its code turns numbers, dates and enums into text using locale tables that are compiled in at build time. It never runs processes, reaches the network or touches the filesystem with untrusted input. I checked each sink the scan flagged. (1) .agents/skills/add-locale-batch/scripts/locale_batch_status.py: run_gh calls subprocess.run with an argument list and no shell. The arguments come from the CLI user's own --repo/--status flags and the PR numbers in their local JSON file. The only file it writes is the --status path the user names, so it crosses no trust boundary. (2) website/scripts/verify-pagefind.mjs is a local build-verification script that starts a server on the docs output it just built. Only the developer running it can reach it. (3) website/src/theme/Root/index.tsx: the dangerouslySetInnerHTML is a fixed string ('<pagefind-modal reset-on-close></pagefind-modal>'). The window.location.replace target comes from legacyRedirects.mjs, which checks at module load that every redirect destination is a local path ('/' but not '//'). It reads the referrer only when it has the same origin and the path appears in a static redirects.json, so there is no open redirect or XSS that an attacker controls. (4) GitHub workflows: docs.yml runs on pull_request, not pull_request_target. It sets top-level permissions to {}. Jobs with contents: write or pages: write are gated on push/workflow_dispatch, so code from a fork PR never runs with a write token or secrets. The NamespaceMigrationAnalyzer that ships in the package only inspects syntax and runs nothing. None of these paths gives an attacker code execution, credential theft, arbitrary file access or control of the repo or pipeline.