Skip to content

formatText (slugify, capitalize)

String transforms and slug generation.

6.6 KB
•
Updated on September 3, 2026

Installation

Bash

Usage

Code

API Reference

capitalizeText(text, options?)

Capitalizes text by sentence, words, or first letter while optionally lowercasing the rest.

Shorthand helpers:

  • capitalizeWords(text, options?) - Shorthand for capitalizeText(text, { mode: 'words' }).
  • capitalizeFirst(text, options?) - Shorthand for capitalizeText(text, { mode: 'first' }).
  • capitalize(text, options?) - Alias for capitalizeText.

truncateText(text, options?)

Truncates a string by character or word count and adds an ellipsis.

randomWord(options?)

Generates pseudo-Latin random words without external dictionaries.