Skip to content

Repository files navigation

StringKit icon

StringKit

FULL DOCUMENTATION: https://dennisturco.github.io/StringKit/

A lightweight .NET library of extension methods for common string transformations and formatting.

CoverageDownloadsNuGetLicense: MIT

Installation

dotnet add package StringKit

Features

  • Case conversion: ToSlug, ToSnakeCase, ToCamelCase, ToPascalCase, ToTitleCase, ToSentenceCase
  • Truncation: Truncate (by characters) and TruncateWords (by word count)
  • Normalization: NormalizeSpaces, RemoveDiacritics, RemoveSpecialChars, NormalizeNewLines, StripHtml, CollapseWhitespace, JoinLines
  • Privacy / PII masking: Redact, MaskEmail, MaskPhone
  • Search & comparison: ContainsAny, ContainsAll, StartsWithAny, EndsWithAny, EqualsIgnoreCase
  • Validation: IsEmail, IsUrl, IsNumeric, IsAlpha, IsAlphanumeric, IsNullOrWhiteSpace, HasMinLength, HasMaxLength
  • Encoding / decoding: ToBase64, FromBase64, UrlEncode, UrlDecode, HtmlEncode, HtmlDecode
  • Utilities: Repeat, Reverse
  • Zero external dependencies: pure .NET BCL
  • All methods are static and thread-safe

Usage

usingStringKit;// Case conversion & truncation"hello world".ToSlug()// "hello-world""hello world".ToCamelCase()// "helloWorld""hello world".ToPascalCase()// "HelloWorld""hello world".ToSnakeCase()// "hello_world""hello world".ToTitleCase(newCultureInfo("en-US"))// "Hello World""Hello World".Truncate(6)// "Hello...""ab".Repeat(3)// "ababab""hello".Reverse()// "olleh"// Normalization" ciao mondo ".NormalizeSpaces()// "ciao mondo""café".RemoveDiacritics()// "cafe""Hello! @#$%".RemoveSpecialChars()// "Hello""<p>Hello <b>World</b></p>".StripHtml()// "Hello World"// Privacy / PII masking"mario@mail.it".MaskEmail()// "m****@mail.it""3331234567".MaskPhone()// "333*****67"// Search & comparison"Hello World".ContainsAny("World","Foo")// true"Hello".EqualsIgnoreCase("hello")// true// Validation"mario@mail.it".IsEmail()// true"12345".IsNumeric()// true"Hello".HasMinLength(3)// true// Encoding / decoding"Hello".ToBase64()// "SGVsbG8=""hello world".UrlEncode()// "hello+world""<b>Hi</b>".HtmlEncode()// "&lt;b&gt;Hi&lt;/b&gt;"

Contributing

Contributions are welcome! Please open an issue or pull request on GitHub.

See CONTRIBUTING.md for guidelines.

License

License: MIT

About

Lightweight, zero-dependency .NET library of string extension methods for case conversion, normalization, PII masking, validation, and encoding.

Topics

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages