Skip to content

Predefined Formats

Caleb Ephrem edited this page Sep 23, 2025 · 4 revisions

🧰 Predefined Formats

UCID comes with a rich set of predefined formats so you don’t have to memorize or manually configure every option. Whether you're mimicking UUIDs, generating short session tokens, or hashing-like IDs, UCID has you covered.

βš™οΈ What Are Predefined Formats?

Predefined formats are shortcut aliases for common ID styles. Internally, they map to specific configuration presets β€” so calling ucid.format('uuid') is equivalent to passing a full config object.

Example:

ucid.format('uuid');
// Result: afe5791b-788a-0c72-dc61-34b008e3fd98

Under the hood, this is equivalent to:

ucid({
  octets: 5,
  octetFormat: [8, 4, 4, 4, 12],
  includeOnly: '1234567890abcdef',
});
// Result: afe5791b-788a-0c72-dc61-34b008e3fd98

🧠 Format Aliases

Each format supports multiple aliases for convenience. For example, 'uuid', 'uuidv4', 'universal', and 'universal-id' all point to the same configuration.

πŸ“ƒ Predefined Format List

Here’s a list of supported formats and their aliases:

  • uuid, uuidv4, universal, universal-id
  • nanoid, nano, nano-id
  • ksuid
  • cuid
  • ulid
  • snowflake, snowflake-id
  • sha, sha1
  • sha256
  • sha512
  • md5
  • object, objectid, object-id
  • mongo, objectid24
  • objectid32
  • digits, numeric
  • alphanumeric
  • alpha
  • ts-id, timestamp-id
  • epoch-id
  • jwt-id
  • bcrypt-id
  • argon-id
  • host-id, machine-id
  • session-id
  • short, mini, ghost, phantom, ninja
  • shortuuid, short-uuid, short-uuidv4
  • hex, hexadecimal
  • shortucid, short-ucid
  • snake-case
  • separatorless, sepless, separator-less
  • zulu
  • slug
  • dna
  • leet
  • caps, capsid, caps-id
  • wordy

πŸ§ͺ Usage Examples

ucid.format('uuid'); // uuidv4, universal or universal-id also works
// Result: dfe4e75c-c765-3cbe-012f-4e7651664b51

ucid.format('sha');
// Result: b216a7459df37c38b701ac2b5ad1ad5c634260f2

ucid.format('nanoid');
// Result: ejw86nXOHfVdAF47xNZBZ

ucid.format('cuid');
// Result: cisg9117yq8fn6xjsrjtdamxh

ucid.format('short-uuid');
// Result: a47031b5-5597-9828-65d1f632

ucid.format('mongo');
// Result: ea06fd984b10b1b03a672c54

ucid.format('ts-id');
// Result: 20250920-t315ny-d4huye

ucid.format('hex');
// Result: 9f5ada13-58cb5d69-4394f491-ee975ef8

ucid.format('short-ucid');
// Result: brxgx5ab-gwc1vvpa-osw3dm5c

βœ… Remember

  • Use predefined formats for consistency across environments.
  • For hashing-like formats (sha, md5, etc.), remember these are not actual cryptographic hashes β€” just structural mimics.

Next up β†’ CLI

Clone this wiki locally