Toolorah

UUID 生成器

批量生成随机 v4 UUID,支持大写、无连字符和括号等选项。

Version 4 (random) UUIDs, generated locally with the browser's cryptographic random source. Nothing leaves your device.

什么是 UUID 生成器?

This generates version 4 UUIDs — the random kind — using your browser’s built-in crypto.randomUUID(). That matters more than it sounds: the values come from the same cryptographically secure random source the browser uses for keys, not from Math.random(), and they are produced on your machine rather than handed to you by a server.

A version 4 UUID is 128 bits with six of them spoken for: four identify the version and two identify the variant. The remaining 122 are random. That is where the practical uniqueness guarantee comes from, and it is why nobody coordinates UUID generation — the odds of two independently generated v4 values colliding are small enough to design around.

Formatting is applied after generation, in a fixed order: hyphens are removed first, then the value is uppercased, then braces are wrapped around the outside. Combining all three gives you the braced, unhyphenated uppercase form some Microsoft tooling expects.

使用场景

Primary keys generated before insert

A UUID lets the application decide an object’s identity without asking the database first, which is what makes offline-first clients and multi-writer systems workable. The trade is index locality: random keys scatter writes across a B-tree in a way sequential integers do not.

Idempotency and correlation keys

Attach one to a request so a retry can be recognised as the same operation rather than a second one. The same value threaded through logs across services turns a pile of separate log lines into one traceable path.

Test fixtures and seed data

Generating a batch gives you identifiers that will not collide with anything real and are obviously synthetic when you find them later in a database.

Filenames for uploads

Naming a stored file after a UUID rather than what the user called it removes an entire class of problems: collisions, path traversal, encoding issues, and leaking the original filename to anyone who sees the URL.

示例

示例 1

Standard form

The default: lowercase hexadecimal in 8-4-4-4-12 groups. The 13th hex digit is always 4, marking the version.

输入 No options selected
输出 f47ac10b-58cc-4372-a567-0e02b2c3d479
示例 2

Compact form

Hyphens removed leaves 32 hex characters. Useful in URLs and filenames, and it is the same value — hyphens are presentation, not data.

输入 No hyphens
输出 f47ac10b58cc4372a5670e02b2c3d479
示例 3

Registry form

All three options together. Hyphens go first, then uppercasing, then the braces are added around the result.

输入 No hyphens + Uppercase + Braces
输出 {F47AC10B58CC4372A5670E02B2C3D479}

UUID 生成器 对比 an auto-incrementing integer

The usual alternative for a primary key. Neither is better in general; they fail in different places.

功能 Toolorah an auto-incrementing integer
Can be generated before insert Yes No — the database assigns it
Safe to merge across databases Yes No — the ranges collide
Leaks how many records exist No Yes — id 8 implies seven before it
Storage per key 16 bytes binary, 36 as text 4 or 8 bytes
Index locality on insert Poor — writes scatter Good — writes append
Readable over the phone No Yes

UUID 生成器 使用技巧

  • Up to 100 at a time. Ask for more and the count is clamped; ask for zero or a non-number and you get one.
  • These are version 4 only. If you need time-ordered identifiers for database insert performance, you want UUIDv7, which this tool does not generate — v4 values are deliberately unordered.
  • Do not use a UUID as a secret. It is unguessable in practice, but it is designed to be an identifier: it gets logged, put in URLs, and shown in error messages. Anything that needs to stay secret needs a token you treat as one.
  • Store them as a native uuid or 16-byte binary column rather than as a 36-character string. The text form costs more than twice the space and indexes worse.
  • crypto.randomUUID() is only available in a secure context, meaning HTTPS or localhost. That is why this page works here and would silently fail on a plain-HTTP copy of it.

常见问题解答

Which UUID version is this?

Version 4, the random one, generated by the browser’s crypto.randomUUID(). Version 1 encodes a timestamp and a MAC address, which leaks information about the machine that made it. Version 7 is the newer time-ordered design intended to index better. This tool produces v4 and nothing else.

Are these random enough to rely on?

Yes. crypto.randomUUID() draws from the platform’s cryptographically secure random number generator — the same source used for cryptographic key material — not from Math.random(), which is fast but predictable and unsuitable for anything where guessability matters.

Could I ever get the same UUID twice?

Not in any system you are likely to build. With 122 random bits, you would need to generate on the order of a billion values a second for decades before a collision became likely. In practice, duplicate UUIDs in production come from bugs — a value copied and reused, or a broken random source — rather than from chance.

Are the UUIDs generated on your server?

No, and this is the main reason to prefer a client-side generator. The values are produced in your browser and never transmitted, so there is no server-side log of identifiers you may be about to use as database keys. A generator that produced them server-side would have a record of every value it handed out.

Why are there only 122 random bits, not 128?

Six bits are fixed by the specification. Four encode the version, which is why the 13th hex digit of a v4 UUID is always 4, and two encode the variant, which is why the 17th is always 8, 9, a, or b. Those positions carry no randomness, leaving 122 bits that do.

Does uppercase or removing hyphens change the value?

No. UUIDs are case-insensitive by specification and the hyphens are purely for readability, so all three formats represent the same 128-bit number. Systems that compare them as strings, though, will not agree — normalise to one form before storing or comparing.