Prefixed ID Generator

ID with custom prefix

Enter values above and click Generate

About

Prefixed IDs combine a custom prefix with a random suffix. They're useful for categorizing identifiers, adding branding, or creating namespaced IDs. The prefix helps identify the type or source of the ID, while the random suffix ensures uniqueness. Common patterns include 'USER-', 'ORDER-', 'TXN-' etc. Prefixed IDs make it easy to identify the type or category of an identifier at a glance, which is helpful for debugging, logging, and system organization.

Use Cases

  • Categorizing identifiers by type (USER, ORDER, etc.)
  • Adding branding to IDs
  • Creating namespaced identifiers
  • Database IDs with type prefixes
  • API identifiers with resource type
  • System organization and debugging

How to Generate

Library

nanoid

NPM Package

npm install nanoid

Code Example

import { nanoid } from 'nanoid';

const prefix = 'USER';
const randomPart = nanoid(12);
const prefixedId = `${prefix}-${randomPart}`;
console.log(prefixedId); // e.g., 'USER-V1StGXR8_Z5j'