Skip to main content
Version: 3.0.1

Humanizer.StringHumanizeExtensions

StringHumanizeExtensions Class

Contains extension methods for humanizing string values.

public static class StringHumanizeExtensions

Inheritance System.Object → StringHumanizeExtensions

Methods

StringHumanizeExtensions.Humanize(this string) Method

Transforms a string into a human-readable format by intelligently handling PascalCase, camelCase, underscored_strings, and dash-separated-strings, converting them into space-separated text with appropriate capitalization.

public static string Humanize(this string input);

Parameters

input System.String

The string to be humanized. Must not be null.

Returns

System.String
A humanized version of the input string with spaces inserted between words and appropriate capitalization. Preserves all-uppercase acronyms unchanged.

Example

"PascalCaseInputString".Humanize() => "Pascal case input string"
"Underscored_input_String_is_turned_INTO_sentence".Humanize() => "Underscored input String is turned INTO sentence"
"dash-separated-string".Humanize() => "Dash separated string"
"HTML".Humanize() => "HTML"
"camelCaseText".Humanize() => "Camel case text"

Remarks

The method applies several rules in order: - If the entire input is uppercase (an acronym), it returns unchanged - Handles freestanding underscores/dashes (e.g., "some _ string") - Splits on underscores and dashes - Breaks up PascalCase and camelCase text The first letter of the result is always capitalized.

StringHumanizeExtensions.Humanize(this string, LetterCasing) Method

Transforms a string into a human-readable format and applies the specified letter casing.

public static string Humanize(this string input, Humanizer.LetterCasing casing);

Parameters

input System.String

The string to be humanized. Must not be null.

casing LetterCasing

The desired letter casing to apply to the humanized result.

Returns

System.String
A humanized version of the input string with the specified casing applied.

Example

"PascalCaseInputString".Humanize(LetterCasing.AllCaps) => "PASCAL CASE INPUT STRING"
"PascalCaseInputString".Humanize(LetterCasing.LowerCase) => "pascal case input string"
"PascalCaseInputString".Humanize(LetterCasing.Title) => "Pascal Case Input String"

Remarks

This is a convenience method that combines Humanize(this string) with ApplyCase(this string, LetterCasing).