TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The UX of UUIDs

216 pointsby jlaneveabout 1 year ago

36 comments

TehShrikeabout 1 year ago
&gt; One way to enhance the usability of unique identifiers is by making them easily copyable.<p>No matter what your identifiers look like, if you want them to be easily copyable you should add `user-select: all` to the element containing them.<p>If you do this, all of the text will be selected automatically when you click on the element.<p><a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;CSS&#x2F;user-select" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;CSS&#x2F;user-select</a>
评论 #40006329 未加载
评论 #40006408 未加载
评论 #40007869 未加载
评论 #40008644 未加载
评论 #40006934 未加载
评论 #40014819 未加载
评论 #40007378 未加载
评论 #40007640 未加载
评论 #40007755 未加载
评论 #40009387 未加载
Terr_about 1 year ago
&gt; One way to enhance the usability of unique identifiers is by making them easily copyable. This can be achieved by removing the hyphens from the UUIDs,<p>No! That&#x27;s throwing the baby out with the bathwater! Removing all separators means rare-but-important manual tasks of transcription or comparison become terrible, since there are no clear chunks.<p>Instead use a different character which doesn&#x27;t have the same problem, one that most software considers part of the same &quot;word&quot;... such as the classic underscore.<p>For most people, double-clicking on this 123_456_789 will select all 9 important numbers. (And maybe a trailing space, but that&#x27;s a separate problem.)
评论 #40007894 未加载
评论 #40005112 未加载
评论 #40008374 未加载
评论 #40010493 未加载
评论 #40006684 未加载
tlrobinsonabout 1 year ago
A couple other potentially desirable properties you could incorporate:<p>- K-sortable: ensures good locality when used as an id in a database (e.x. <a href="https:&#x2F;&#x2F;github.com&#x2F;jetify-com&#x2F;typeid">https:&#x2F;&#x2F;github.com&#x2F;jetify-com&#x2F;typeid</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;segmentio&#x2F;ksuid">https:&#x2F;&#x2F;github.com&#x2F;segmentio&#x2F;ksuid</a> )<p>- checksum: primarily useful when an id might be conveyed verbally (e.x. customer support) or transcribed (e.x. Bitcoin wallet backup, BIP-39)
评论 #40006795 未加载
评论 #40008342 未加载
评论 #40007783 未加载
评论 #40008486 未加载
shinzuiabout 1 year ago
The author seems to be unaware of TypeID. You can use TypeID and ignore this article.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;jetify-com&#x2F;typeid">https:&#x2F;&#x2F;github.com&#x2F;jetify-com&#x2F;typeid</a>
评论 #40004936 未加载
评论 #40006786 未加载
评论 #40006623 未加载
评论 #40006287 未加载
评论 #40007805 未加载
simonwabout 1 year ago
Related note: Amazon IAM credentials often look something like this (not real):<p><pre><code> aws_access_key_id = AKIA367COJQOEU3UOE aws_secret_access_key = a7Ed0F80a0AF6606&#x2F;MQG3+4o&#x2F;o </code></pre> It&#x27;s frustrating that you can select the access key by double clicking it but not the secret access key because of those &#x2F; characters.
评论 #40007990 未加载
swyxabout 1 year ago
i keep a list of UUID reading and desirable properties here! <a href="https:&#x2F;&#x2F;github.com&#x2F;swyxio&#x2F;brain&#x2F;blob&#x2F;master&#x2F;R%20-%20Dev%20Notes&#x2F;uuid%20list.md">https:&#x2F;&#x2F;github.com&#x2F;swyxio&#x2F;brain&#x2F;blob&#x2F;master&#x2F;R%20-%20Dev%20No...</a>
评论 #40006832 未加载
评论 #40007460 未加载
评论 #40005291 未加载
Daegalusabout 1 year ago
As someone who maintains a UUID library, this is definitely something that has been thought about, especially in the UUIDv6-v8 updates. But it was moved to be considered later as an extension after v6-v8 get approved fully.<p>But all these were talked about and considered before it was punted to a later time. <a href="https:&#x2F;&#x2F;github.com&#x2F;uuid6&#x2F;uuid6-ietf-draft&#x2F;issues&#x2F;27">https:&#x2F;&#x2F;github.com&#x2F;uuid6&#x2F;uuid6-ietf-draft&#x2F;issues&#x2F;27</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;uuid6&#x2F;new-uuid-encoding-techniques-ietf-draft">https:&#x2F;&#x2F;github.com&#x2F;uuid6&#x2F;new-uuid-encoding-techniques-ietf-d...</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;uuid6&#x2F;new-uuid-encoding-techniques-ietf-draft&#x2F;issues&#x2F;4">https:&#x2F;&#x2F;github.com&#x2F;uuid6&#x2F;new-uuid-encoding-techniques-ietf-d...</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;uuid6&#x2F;new-uuid-encoding-techniques-ietf-draft&#x2F;issues&#x2F;2">https:&#x2F;&#x2F;github.com&#x2F;uuid6&#x2F;new-uuid-encoding-techniques-ietf-d...</a><p>But there is always TypeID in the meantime which uses UUIDv7 under the hood: <a href="https:&#x2F;&#x2F;github.com&#x2F;jetify-com&#x2F;typeid">https:&#x2F;&#x2F;github.com&#x2F;jetify-com&#x2F;typeid</a><p>Either way, I am in favor of prefixing and using alternative encodings, but it will need some time to figure out the best route. In the mean time, there are so many alternatives. TypeID, NanoID, ULID, etc. I even made my own quick one just for giggles: <a href="https:&#x2F;&#x2F;github.com&#x2F;daegalus&#x2F;snowflakes">https:&#x2F;&#x2F;github.com&#x2F;daegalus&#x2F;snowflakes</a>
sgarlandabout 1 year ago
&gt; In our MySQL database we use IDs mostly as primary key<p>Clustered index with random data stored as chars as the PK, what a great time! You will surely not regret this decision later.
评论 #40007555 未加载
评论 #40014826 未加载
评论 #40007496 未加载
silvestrovabout 1 year ago
Problem with using base58 is that it uses 24 letters (excl &#x27;I&#x27;) so you can end up with 4 letter words that the marketing&#x2F;PR departments does not like.<p>Hexadecimal is safe.
评论 #40005079 未加载
评论 #40006423 未加载
评论 #40005587 未加载
评论 #40007195 未加载
pimlottcabout 1 year ago
&gt; Try copying this UUID by double-clicking on it<p>Nobody does this. Normal users don&#x27;t even know this is a thing. I worked on an app that did something like this for placeholders in generated text, and in all our extensive testing and high-touch rollouts, we never saw anyone use it.<p>It&#x27;s nice that you took the time to think about it, but it&#x27;s not that important.
评论 #40007715 未加载
评论 #40007697 未加载
评论 #40007512 未加载
评论 #40007688 未加载
djbusbyabout 1 year ago
Can use ULID to &quot;fix&quot; some issues<p><a href="https:&#x2F;&#x2F;github.com&#x2F;ulid&#x2F;spec">https:&#x2F;&#x2F;github.com&#x2F;ulid&#x2F;spec</a>
评论 #40004840 未加载
nikeeeabout 1 year ago
I built cybertoken [1] for API keys and passwords, not (only) IDs. It is basically the format that GitHub uses for their api keys. Underscores, a prefix, so we can get a better debugging experience and automated secret scanning. It also has a CRC32, so you can check offline if the token candidate is a cybertoken while doing secret scanning.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;nikeee&#x2F;cybertoken">https:&#x2F;&#x2F;github.com&#x2F;nikeee&#x2F;cybertoken</a>
jcgrilloabout 1 year ago
I&#x27;d rather focus on optimizing the size of uuids than their text representation. Shipping uuids around as utf-8 text is silly. They&#x27;re <i>at most</i> 128bits, so we shouldn&#x27;t use more than that many.<p>In the case where it&#x27;s necessary to have a text representation (e.g. in some user interface) I guess it&#x27;s fine to choose whatever (stable) transformation you like, but the standard ways specified in RFC-4122 (hexadecimal, with or without hyphens) seem like the most foolproof. Regarding the logs search use case, the first &quot;chunk&quot; of a uuid is usually well more than enough for a unique match, IME.<p>Also, I&#x27;ve been burned before in cases where some clever transformation was used to make a uuid look different in text form, because in order to synthesize the actual binary uuid I first have to reverse engineer the transformation--e.g. to find the database record corresponding to some http request log message. That&#x27;s just annoying, and the polar opposite of &quot;user friendly&quot; for the user story of an engineer trying to figure out what&#x27;s wrong with the system.<p>So.. I guess my vote is to stick to the standard.
评论 #40008433 未加载
hot_grilabout 1 year ago
&quot;Let’s not pretend like we are Google or AWS who have special needs around this. Any securely generated UUID with 128 bits is more than enough for us.&quot;<p>Thank you. This is overthought so much, including with partially-random things like uuid3, 5, 7.
评论 #40008363 未加载
__MatrixMan__about 1 year ago
An even better UUID UX would cycle through colors when you clicked one and then would overlay the assigned color when you see that same UUID elsewhere. Better to find a needle in a haystack if it&#x27;s the only one with a pink background.
评论 #40006528 未加载
throwaway35777about 1 year ago
base58 is case sensitive which hinders readability. When devs work with uuids they typically remember the first few letters (&quot;this is guid abc&quot;, &quot;that one is guid 1ac&quot;). Hard to do that in base58.<p>The coarsest encoding to have this property is Base32 where it remains easy to memorize first few letters without needing to memorize case.
AirMax98about 1 year ago
&gt; TLDR: Please don&#x27;t do this: <a href="https:&#x2F;&#x2F;company.com&#x2F;resource&#x2F;c6b10dd3-1dcf-416c-8ed8-ae561807fcaf" rel="nofollow">https:&#x2F;&#x2F;company.com&#x2F;resource&#x2F;c6b10dd3-1dcf-416c-8ed8-ae56180...</a><p>But like... why? This article literally does not explain the benefits beyond copying, they are just assumed. I&#x27;m not immediately sold on shorter === better, especially when the updated UUIDs are only marginally shorter and you have now introduced the overhead of a translation layer for one of the most basic building blocks in your application.
评论 #40006451 未加载
评论 #40010555 未加载
IncreasePostsabout 1 year ago
Why would readability of a UUID matter? At most, users should by copy-pasting them, not reading them or trying to memorize them, so why should I and l and 1 looking similar matter?
评论 #40004837 未加载
评论 #40004834 未加载
评论 #40007492 未加载
kazinatorabout 1 year ago
Here is a thing I <i>wish</i> would Just Work, everywhere.<p>Given:<p><i>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</i><p>I&#x27;d like to, say, double click on <i>consectetur</i> to select it (which works), bt then, while holding Shift, I would like to double click on <i>elit</i> so that the selection of <i>consectetur</i> is preserved, and extended over <i>elit</i>, including <i>adipiscing</i>.<p>The behavior I typically see is that, while holding Shift, the first click will extend the selection to the exact character of <i>elit</i> that I&#x27;m pointing at. The second click will then cancel the selection and select all of <i>elit</i>.<p>Like it doesn&#x27;t mean a damn thing that I&#x27;m holding down Shift!<p>Ironically, I can make multiple selections that way using Ctrl in Firefox; Ctrl does modify the semantics of the second click while there is a selection.
tttpabout 1 year ago
We need to separate the storage format (Postgres and MySQL both have a bigint serial for primary key and it should stay that way)<p>for display, you have various ways to encode that number into something easier for humans, what I prefer:<p>- short word - no offensive words - with a checksum (so we easily spot any copy paste mistake) - not sequential - can be put in a url without extra encoding<p>this is our implementation of that (base32 and luhn code)<p><a href="https:&#x2F;&#x2F;github.com&#x2F;tttp&#x2F;dxid">https:&#x2F;&#x2F;github.com&#x2F;tttp&#x2F;dxid</a>
veidelisabout 1 year ago
&gt; This can be achieved by removing the hyphens from the UUIDs, allowing users to simply double-click on the identifier to copy it.<p>Triple click can be used.
logifailabout 1 year ago
Q: What&#x27;s special about the format of UUIDs compared to, say, an equivalent entropy 128-bit number? For many use cases, the hyphens appear to be utterly irrelevant.<p><a href="https:&#x2F;&#x2F;softwareengineering.stackexchange.com&#x2F;questions&#x2F;385524&#x2F;what-is-the-minimum-length-for-a-uuid" rel="nofollow">https:&#x2F;&#x2F;softwareengineering.stackexchange.com&#x2F;questions&#x2F;3855...</a>
jongjongabout 1 year ago
This is a great point. It&#x27;s unfortunate that few engines and standard libraries implement base58 encoding&#x2F;decoding. This is probably because it is a more complex format because it does not include certain ambiguous letters like l and O. Base64 is relatively straight forward to implement as it maps easily from a number to a character.
kuonabout 1 year ago
For user facing IDs I made base24 which limit the alphabet further to made it case insensitive.<p><a href="https:&#x2F;&#x2F;www.kuon.ch&#x2F;post&#x2F;2020-02-27-base24&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.kuon.ch&#x2F;post&#x2F;2020-02-27-base24&#x2F;</a>
Leftiumabout 1 year ago
TypeScript template literal types can be used to type-check IDs with prefixes: <a href="https:&#x2F;&#x2F;hw.leftium.com&#x2F;#&#x2F;item&#x2F;39174998" rel="nofollow">https:&#x2F;&#x2F;hw.leftium.com&#x2F;#&#x2F;item&#x2F;39174998</a>
MrBuddyCasinoabout 1 year ago
If you expose UUIDs to the user, even if just as part of the URL, encode them as shortUUID: <a href="https:&#x2F;&#x2F;github.com&#x2F;skorokithakis&#x2F;shortuuid">https:&#x2F;&#x2F;github.com&#x2F;skorokithakis&#x2F;shortuuid</a>
rickcarlinoabout 1 year ago
I’ve always felt that Crockford Base 32 was very ergonomic. <a href="http:&#x2F;&#x2F;www.crockford.com&#x2F;base32.html" rel="nofollow">http:&#x2F;&#x2F;www.crockford.com&#x2F;base32.html</a>
_akheabout 1 year ago
Do they really have to be that long? And why can&#x27;t they just be 4-4-4-4 (I&#x27;m sure someone knows). In hobby apps I often .split(&#x27;-&#x27;)[0] lol the first 8 is fine (so far)
eviksabout 1 year ago
Good points, wish they were specced into the original uuids so you don&#x27;t need to postprocess (except for prefixes add those are more user-specific)
kazinatorabout 1 year ago
You also can&#x27;t easily copy the word &quot;double-click&quot; by just double-clicking on it.<p>Maybe the browser (and other) UI is wrong about word boundaries.
pyuser583about 1 year ago
Isn’t there some encoding that encodes bytes as words, or pronounceable letter groupings?
pphyschabout 1 year ago
The UX of UUIDs... should not exist. There are so many great ways to improve UX that don&#x27;t involve overloading or mangling an internal primary identifier that otherwise follows a standard structure.<p>Use immutable human-readable identifiers like &quot;slugs&quot; and&#x2F;or &quot;natural keys&quot; in addition to robust primary keys.<p>&gt; TLDR Please don&#x27;t do this: <a href="https:&#x2F;&#x2F;company.com&#x2F;resource&#x2F;c6b10dd3-1dcf-416c-8ed8-ae561807fcaf" rel="nofollow">https:&#x2F;&#x2F;company.com&#x2F;resource&#x2F;c6b10dd3-1dcf-416c-8ed8-ae56180...</a><p>That URL is fine, it should just be a 30X to <a href="https:&#x2F;&#x2F;company.com&#x2F;stuff&#x2F;cute-slug" rel="nofollow">https:&#x2F;&#x2F;company.com&#x2F;stuff&#x2F;cute-slug</a> and you should use the user-friendly URL where possible.
评论 #40009906 未加载
pmarreckabout 1 year ago
UUIDv7 is great.<p>The PGP Word List for translating hex into words: exists.
briantakitaabout 1 year ago
Why is Base58 used instead of Base64?
评论 #40008887 未加载
rendallabout 1 year ago
I at first misread &quot;TLDR; Please don&#x27;t do this:&quot; as applying to the <i>entire</i> article. I read it expecting a kind of McSweeney&#x27;s parody where it gives you terrible advice. Really confused because the advice was good and not funny.
评论 #40009569 未加载
compressedgasabout 1 year ago
Except that UUIDs by themselves don&#x27;t do this at all:<p>&gt; They provide a reliable way to ensure that each item, user, or piece of data has a unique identity.<p>It is the registration of a UUID in a database which prohibits reuse that does that. If you aren&#x27;t do doing that, ensuring that each use of a UUID is not a reuse of an already assigned UUID, they are not UNIQUE.
评论 #40004696 未加载
评论 #40004630 未加载
评论 #40004934 未加载
评论 #40004707 未加载
评论 #40004679 未加载
评论 #40004628 未加载
评论 #40004614 未加载
评论 #40004765 未加载