How to Generate a UUID on Mac (uuidgen, v7, ULID)
Generate a UUID on Mac with uuidgen in Terminal, make it lowercase and copy it, then create UUID v7, ULIDs or Nano IDs in bulk and decode existing IDs.
GuideUpdated 7 min read
On this page
To generate a UUID on a Mac, open Terminal and run uuidgen. It prints a new UUID in uppercase, such as 3F2504E0-4F89-41D3-9A0C-0305E82C3301. To get a lowercase UUID straight onto the clipboard, run uuidgen | tr '[:upper:]' '[:lower:]' | tr -d '\n' | pbcopy.
uuidgen can't make UUID v7, ULIDs or Nano IDs. It also can't generate many IDs in one call or tell you what an existing ID contains. The sections below cover each of those cases.
Generate a UUID on Mac with uuidgen
uuidgen ships with macOS, so there's nothing to install.
- Open Terminal. It's in Applications ▸ Utilities, or you can search for it with Spotlight.
- Run the command:
uuidgenThis prints one UUID followed by a line break, and each run gives a new value. The first character of the third group is the UUID version. On current macOS it's 4, which means a random (version 4) UUID. To check it yourself, print only that character:
uuidgen | cut -c15The macOS uuidgen has one documented option, -hdr, which prints CoreFoundation source code for using the UUID in a header. Guides for Linux show flags for time-based and random UUIDs. Those come from the util-linux version of uuidgen and don't exist on macOS.
Make it lowercase and copy it to the clipboard
macOS uuidgen prints uppercase. If your code or API expects lowercase, pipe the output through tr:
uuidgen | tr '[:upper:]' '[:lower:]'This converts every uppercase letter to lowercase and doesn't change any setting.
To copy the UUID instead of printing it, send it to pbcopy. Strip the trailing line break first, otherwise it gets pasted along with the ID:
uuidgen | tr '[:upper:]' '[:lower:]' | tr -d '\n' | pbcopyThis makes a lowercase UUID, removes the newline and puts the result on the clipboard. Press ⌘V (Command-V) to paste it anywhere.
If you do this often, add an alias to ~/.zshrc:
alias uuid="uuidgen | tr '[:upper:]' '[:lower:]' | tr -d '\n' | pbcopy"After you open a new Terminal window, uuid copies a fresh lowercase UUID. To undo this, delete the line from ~/.zshrc.
If Python 3 is installed, python3 -c 'import uuid; print(uuid.uuid4())' also prints a random UUID, already in lowercase.
Make UUID v7, ULID or Nano ID
uuidgen can't make these. These are the common reasons to want them:
- UUID v7 starts with a 48-bit Unix timestamp in milliseconds, so newer IDs sort after older ones. Database indexes stay tidier than with random v4 IDs.
- ULID also starts with a millisecond timestamp. It's written as 26 characters of Crockford Base32, with no hyphens.
- Nano ID is a short random ID that uses a URL-safe alphabet. The usual length is 21 characters.
- UUID v3 and v5 are deterministic. The same namespace and name always produce the same UUID.
We make Bytepliers, a Mac app of offline developer tools. Its UUID / ULID tool generates all of these:
- Open Bytepliers and press ⌘6 (Command-6) to open UUID / ULID. You can also press ⌘K and type "make a uuid".
- In the Generate pane, open the Kind menu and choose the type: UUID v1, v3, v4 (the default), v5, v6, v7, ULID, Nano ID, ObjectId or KSUID.
- Set the count. The range is 1 to 1,000 and the default is 5.
- For UUIDs, set Uppercase and Hyphens to match the format you need.
- Press ⌘R (Command-R) to regenerate.
- Press ⇧⌘C (Shift-Command-C) to copy the output.


Some kinds have extra options:
- v3 and v5: pick a namespace (DNS, URL, OID, X.500 or Custom) and enter names, one per line. You get one UUID per name.
- Nano ID: set the size from 2 to 256 (default 21) and edit the alphabet. Reset restores the default alphabet.
Everything is generated on your Mac. The tool doesn't use the network.
Generate many UUIDs at once
With uuidgen, use a loop. This prints 10 UUIDs, one per line:
for i in {1..10}; do uuidgen; doneChange 10 to the number you need. To make them lowercase and copy all of them:
for i in {1..10}; do uuidgen; done | tr '[:upper:]' '[:lower:]' | pbcopyThe loop works for any count. It starts a separate process for each ID, though, so it slows down at large counts, and it only makes v4 UUIDs.
The Bytepliers UUID / ULID tool makes up to 1,000 IDs of any kind per batch. For more than that, or for use in scripts, use the command-line tool below.
Decode an existing UUID
macOS has no built-in command that explains what's inside a UUID. You can read two things by hand:
- Version: the first character of the third group.
cut -c15prints it, as shown above. - Time in a UUID v7: the first 12 hex characters are milliseconds since 1970. These are the 8 characters before the first hyphen plus the 4 after it. Remove the hyphen, put
0xin front, and let the shell do the arithmetic:
date -r $(( 0x01932c07a0e0 / 1000 ))Replace 0x01932c07a0e0 with the first 12 hex digits of your UUID. The command prints that moment in your local time. For UTC, add -u before -r. The command only reads the value and changes nothing. Our guide to converting Unix timestamps on Mac covers date in more detail.
For anything more, use the decode pane in the Bytepliers UUID / ULID tool:
- Press ⌘6 to open UUID / ULID.
- Paste the ID into the decode field (placeholder "UUID, ULID, ObjectId, Snowflake or KSUID"), or click the paste-from-clipboard button.
- Read the Structure section. Depending on the type, it shows the version, variant, time, clock sequence, node and random bits.
- Expand Conversions to see the same ID as hex, Base64, a 128-bit decimal and bytes, plus ULID ↔ UUID.
The field accepts UUIDs in canonical form, in braces, as a URN, as 32 bare hex characters and in Base64 forms. For Snowflake IDs, choose the epoch (Twitter / X or Discord) so the time comes out right. After generating IDs, click Decode the first ID to send the first one to the decode pane.


Generate IDs from the command line with bytepliers
Bytepliers includes a bytepliers command that works even when the app isn't running. To install it:
- Open Bytepliers.
- Go to Settings ▸ Integrations ▸ Command-Line Tool.
- Click Install… and choose
/usr/local/binor~/.local/bin.
macOS asks for an administrator password only if /usr/local/bin isn't writable. If you choose ~/.local/bin, that folder must be on your shell's PATH. The command-line tool docs cover setup.
| Command | What it does |
|---|---|
bytepliers uuid | One random v4 UUID (--v4 is the default) |
bytepliers uuid --v7 | One UUID v7 |
bytepliers uuid --ulid | One ULID (always uppercase) |
bytepliers uuid -n 500 | 500 IDs (the count can be 1 to 10,000) |
Run bytepliers help for every option.
This command overwrites ids.txt if it already exists:
bytepliers uuid --v7 -n 1000 > ids.txtIt writes 1,000 UUID v7 values to ids.txt in the current folder.
This one copies a single UUID v7 to the clipboard without a trailing line break:
bytepliers uuid --v7 | tr -d '\n' | pbcopyThe command-line tool uses the same license as the app, so it works during the trial and with a MacSuite license. Bytepliers is part of MacSuite ($349 one-time as of November 2026), and you can try it free for 7 days.
Which method to use
| Method | ID types | How many at once | Decode |
|---|---|---|---|
uuidgen (built in) | v4 only | One (loop for more) | No |
| Bytepliers UUID / ULID tool | v1, v3–v7, ULID, Nano ID, ObjectId, KSUID | 1–1,000 | Yes, with structure and conversions |
bytepliers uuid command | v4, v7, ULID | 1–10,000 | No |
- Use
uuidgenfor an occasional random UUID. It's already on your Mac. - Use the Bytepliers app if you need v7, ULID, Nano ID or deterministic v5 IDs, or want to see what's inside an existing ID.
- Use the
byteplierscommand for scripts, seed data or thousands of v7 IDs at once.
If it doesn't work
- The pasted UUID ends with a line break.
uuidgenends its output with a newline. Addtr -d '\n'beforepbcopy. - Your API rejects uppercase UUIDs. macOS
uuidgenprints uppercase. Pipe it throughtr '[:upper:]' '[:lower:]', or turn off Uppercase in Bytepliers. zsh: command not found: bytepliers. Either the command isn't installed, or it's in~/.local/binand that folder isn't on your PATH. Install it from Settings ▸ Integrations, or add~/.local/binto your PATH and open a new Terminal window.- "Open Bytepliers once to enable the command-line tool." The command needs an access file that the app writes when it opens. Open Bytepliers, then run the command again.
- "Bytepliers needs a license or an active trial." (exit status 77). The trial has ended. Enter a license key in Bytepliers to continue.
- The decode pane says "Unknown format". The text isn't an ID format the tool recognizes. Check for stray characters, quotes or a cut-off value. For a Snowflake ID that decodes to the wrong time, check that you picked the right epoch.
More fixes are in troubleshooting Bytepliers. The Bytepliers tool reference lists every option in the UUID / ULID tool.
FAQ
Are uuidgen UUIDs unique enough for database keys?
Yes. A version 4 UUID has 122 random bits, which makes a collision extremely unlikely. If you index on the key and want rows to sort by insert order, consider UUID v7 instead.
Can uuidgen make a UUID v7?
No. The macOS uuidgen has one documented option (-hdr) and no way to choose the version. Use bytepliers uuid --v7 or the Bytepliers UUID / ULID tool.
Should I use a UUID as a secret token or password?
No. UUIDs are designed to be unique, not secret, and v1, v6 and v7 contain a timestamp anyone can read. For API keys or tokens, use a generator built for secrets, such as the Password Generator in Bytepliers.