# \[Pitch\] UUID v7, other improvements

**URL:** <https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427>\
**Category:** Foundation\
**Created:** [March 18, 2026, 10:30pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427 "2026-03-18T22:30:21Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![sergeyprokhorenko](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sergeyprokhorenko/32/44830_2.png) [@sergeyprokhorenko](https://forums.swift.org/u/sergeyprokhorenko)\
**Post date:** [March 19, 2026, 10:25pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/21 "2026-03-19T22:25:44Z")

</div>

This is a way to erroneously obtain a huge number of identifiers with the same timestamp. Therefore, it is not supported by RFC 9562, and a more safe alternative - timestamp offset - is proposed.

I would recommend thoroughly studying RFC 9562 before making "let's do it just in case" suggestions.

---

<div class="post-metadata">

**Author:** ![jberry](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jberry/32/6360_2.png) [@jberry](https://forums.swift.org/u/jberry)\
**Post date:** [March 19, 2026, 11:12pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/22 "2026-03-19T23:12:23Z")

</div>

@Karl ’s work here might be an interesting comparison: [UniqueID - time-ordered UUIDs in Swift](https://forums.swift.org/t/uniqueid-time-ordered-uuids-in-swift/53265) (He added support for random v4 UUIDS and ordered v6 UUIDs).

---

<div class="post-metadata">

**Author:** ![Lucca-mito](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lucca-mito/32/24744_2.png) [@Lucca-mito](https://forums.swift.org/u/Lucca-mito)\
**Post date:** [March 20, 2026, 8:02pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/23 "2026-03-20T20:02:52Z")

</div>

Other commenters have already expressed preference for `v7` over `timeOrdered`, but I just wanted to add that `v7` is not just clearer and more ergonomic: it also avoids introducing ambiguity if we ever want to support a new version of UUID that’s _also_ time-ordered.

---

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [March 20, 2026, 8:26pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/24 "2026-03-20T20:26:15Z")

</div>

> [@Tony\_Parker](#):
>
> ## Alternatives considered
> 
> ### Adding version as a parameter to `init()`
> 
> Instead of `UUID.timeOrdered()`, we considered `UUID(version: .timeOrdered)`. However, different versions require different parameters — version 5 needs a name and namespace, version 8 needs custom data — so a single initializer would either need to accept many optional parameters or use an associated-value enum. Static factory methods are clearer and allow each version to have its own natural parameter list.

There's this unorthodox way that allows using initialisers with different set of parameters per version:

```swift
extension UUID {
    struct V5 { private init() {}; static let v5 = V5() }
    struct V8 { private init() {}; static let v8 = V8() }
    
    init(_ v5: V5, name: String, namespace: String) { ... }
    init(_ v8: V8, customData: Data) { ... }
    ...
}

```

Usage example:

```swift
UUID(.v5, name: "name", namespace: "namespace")
UUID(.v8, customData: Data())
UUID(.v5, customData: Data()) // compilation error

```

---

<div class="post-metadata">

**Author:** ![Tony\_Parker](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tony_parker/32/273_2.png) [@Tony\_Parker](https://forums.swift.org/u/Tony_Parker)\
**Post date:** [March 20, 2026, 10:09pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/25 "2026-03-20T22:09:17Z")

</div>

Hi all,

I've updated the proposal with the following changes:

- `UUID.timeOrdered` -\> `UUID.version7()`
- Added corresponding `static func version4()`, for completeness.
- Renamed `timeOrderedTimestamp` to simply `date`.
- Removed the entire `Version` struct. There isn't really much point to it, which became clearer when renaming all of its properties to `versionX`.
- Changed the result type of `version` to `Int`.
- Added an `offset` option to the version 7 generation API, alongside the ability to set a specific `Date`.
- Added guarantee of monotonic increments, similar to the postgre approach (thanks @sergeyprokhorenko).

Updated [proposal is here](https://github.com/parkera/swift-foundation/blob/bda240e0d8354288c67de99b7d7b394d08afc8c5/Proposals/NNNN-uuid-versions.md).

---

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [March 20, 2026, 10:24pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/26 "2026-03-20T22:24:34Z")

</div>

> [@Tony\_Parker](#):
>
> `UUID` is in need of a few more additions for modern usage

Question that (only just) occurred to me, but alluded to I think by some other commenters, in the realm of modern usage:

As Wikipedia tells me, "A UUID is a 128-bit number." Now that we have `UInt128` in the standard library, are there type conversions or other APIs that become possible to express in modern Swift using that type which we should now add as part of this modernization?

---

<div class="post-metadata">

**Author:** ![Tony\_Parker](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tony_parker/32/273_2.png) [@Tony\_Parker](https://forums.swift.org/u/Tony_Parker)\
**Post date:** [March 20, 2026, 10:36pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/27 "2026-03-20T22:36:35Z")

</div>

It's a good question. I am hoping that the work on the "fully inhabited" protocols (see [safe loading API for RawSpan](https://github.com/glessard/swift-evolution/blob/rawspan-safe-loading/proposals/nnnn-rawspan-safe-loading-api.md)) will provide a seamless connection between `Span<UInt8>` and `Int128`, when it's useful. That is, an Int128 is inherently Raw, and Raw is inherently `UInt8`. But I will leave the discussion of those points for the other thread, to avoid getting into the weeds on this one.

If if doesn't work out, we could revisit adding conveniences to this type too.

---

<div class="post-metadata">

**Author:** ![erithacus](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/erithacus/32/20377_2.png) [@erithacus](https://forums.swift.org/u/erithacus)\
**Post date:** [March 21, 2026, 9:05am UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/28 "2026-03-21T09:05:25Z")

</div>

> [@Tony\_Parker](#):
>
> `uuidStringLower` vs something else. I think I like `lowercasedUUIDString`, although it doesn't match `uuidString` in the case of `UUID`, it's probably the best alternative. I'll rename it.

Has it been considered making lower cased the default representation from `.uuidString`? As I understand it, the spec states UUIDs should be represented as lowercase.

I think the default should be as spec compliant as possible. One reason it would have tangible impact is that the default being uppercase currently allows implicit identification of iOS users vs other platforms if the UUID is logged without transforming to lowercase.

Making the default match the spec and other implementations would prevent that which seems like a good thing.

---

<div class="post-metadata">

**Author:** ![benrimmington](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/benrimmington/32/695_2.png) [@benrimmington](https://forums.swift.org/u/benrimmington)\
**Post date:** [March 21, 2026, 10:19am UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/29 "2026-03-21T10:19:19Z")

</div>

A previous [pitch](https://forums.swift.org/t/pitch-conform-uuid-to-losslessstringconvertible/80084) to conform `UUID` to `LosslessStringConvertible` was accepted, but the pull requests for the [proposal](https://github.com/swiftlang/swift-foundation/pull/1317) and [implementation](https://github.com/swiftlang/swift-foundation/pull/1303) haven't been merged yet.

Instead of adding a `lowercasedUUIDString` property, you could add an initializer similar to the `String.init(_:radix:uppercase:)` used by binary integers.

```swift
extension String {
  public init(_ uuid: UUID, uppercase: Bool)
}

```

For example:

```swift
String(uuid) //-> "E621E1F8-C36C-495A-93FC-0C247A3E6E5F"
String(uuid, uppercase: true) //-> "E621E1F8-C36C-495A-93FC-0C247A3E6E5F"
String(uuid, uppercase: false) //-> "e621e1f8-c36c-495a-93fc-0c247a3e6e5f"

```

---

<div class="post-metadata">

**Author:** ![erithacus](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/erithacus/32/20377_2.png) [@erithacus](https://forums.swift.org/u/erithacus)\
**Post date:** [March 21, 2026, 12:09pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/30 "2026-03-21T12:09:45Z")

</div>

I like that but think the default should be lowercase 🙂

---

<div class="post-metadata">

**Author:** ![jjatie](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jjatie/32/24428_2.png) [@jjatie](https://forums.swift.org/u/jjatie)\
**Post date:** [March 21, 2026, 2:54pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/31 "2026-03-21T14:54:24Z")

</div>

Why offer a `lowercasedUUIDString` at all? String already has API to achieve this, we’re only saving 3 characters:

```swift
let foo: UUID
foo.uuidString.lowercased()

```

---

<div class="post-metadata">

**Author:** ![FlorianPircher](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/florianpircher/32/39919_2.png) [@FlorianPircher](https://forums.swift.org/u/FlorianPircher)\
**Post date:** [March 21, 2026, 4:50pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/32 "2026-03-21T16:50:30Z")

</div>

I think we could simply name the string accessors `lowercased()` and `uppercased()`, mirroring the String API.

There is a strong connection between a UUID value and its string representation, so in `lowercasedUUIDString` I feel like both the `UUID` and `String` parts are redundant.

---

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [March 21, 2026, 10:45pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/33 "2026-03-21T22:45:13Z")

</div>

> [@erithacus](#):
>
> Has it been considered making lower cased the default representation from `.uuidString`? As I understand it, the spec states UUIDs should be represented as lowercase.

We can't change `uuidString` without risking breaking existing apps.. However this we probably could:

1. deprecate `uuidString`
2. make a new property, say `string` and make that one lowercasing.
3. do not provide uppercasing property/method (thus guiding users away from that). Those who want to uppercase will just call `uuid.string.uppercased()`.

* * *

As for the name for `nil` - I don't think we need to religiously follow the RFC in that regards, the same way we don't want to call that constant `Nil` (as per the RFC).

---

<div class="post-metadata">

**Author:** ![erithacus](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/erithacus/32/20377_2.png) [@erithacus](https://forums.swift.org/u/erithacus)\
**Post date:** [March 21, 2026, 11:18pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/34 "2026-03-21T23:18:51Z")

</div>

I agree. It always struck me that `.uuidString` is a bit of a peculiar name. `.string` more accurately conveys what it is.

---

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [March 21, 2026, 11:22pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/35 "2026-03-21T23:22:31Z")

</div>

> [@tera](#):
>
> However this we probably could:
> 
> 1. deprecate `uuidString`
> 2. make a new property, say `string` and make that one lowercasing.

The idiomatic spelling in Swift, if we're creating new APIs, would be as @benrimmington describes: that is, a converting initializer `String(_: UUID, uppercase: Bool = false)`.

---

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [March 21, 2026, 11:34pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/36 "2026-03-21T23:34:20Z")

</div>

Won't be convenient working with optionals, compare the two:

```swift
struct SomeStruct {
    var field: String?
    ...
}

func foo(uuid: UUID?) {
    SomeStruct(
        field: uuid == nil ? nil : String(uuid!)
        ...
    )
    SomeStruct(
        field: uuid?.string
        ...
    )
}

```

---

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [March 21, 2026, 11:38pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/37 "2026-03-21T23:38:50Z")

</div>

> [@tera](#):
>
> Won't be convenient working with optionals, compare the two:

Orthogonal problem, nothing unique to _this_ converting initializer.  
(Also, you can write `optionalUUID.map(String.init)` in such situations.)

---

<div class="post-metadata">

**Author:** ![erithacus](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/erithacus/32/20377_2.png) [@erithacus](https://forums.swift.org/u/erithacus)\
**Post date:** [March 22, 2026, 9:36am UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/38 "2026-03-22T09:36:18Z")

</div>

> [@xwu](#):
>
> The idiomatic spelling in Swift, if we're creating new APIs, would be as @benrimmington describes: that is, a converting initializer `String(_: UUID, uppercase: Bool = false)`.

Looks good to me + deprecating the `uuidString` property.

@tera - I think your concern could be addressed by also having an initialiser that accepts an optional UUID and returns an optional String. Eg:  
`String(_: UUID?, uppercase: Bool = false)`

Whether that belongs in the standard library I’m not sure, but would be trivial to add as a convenience extension if needed.

---

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [March 22, 2026, 1:05pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/39 "2026-03-22T13:05:42Z")

</div>

We have precedents for having multiple ways of performing such conversions, for example, `String(42)` and `42.formatted()`. That said, providing a single way in this case (such as `String.init`) is sufficient.

However, I would like to see the deprecation of `uuidString` being included in this pitch to better align with RFC 4122 and ITU-T X.667 in guiding users away from uppercased UUID. And to make this guidance consistent we should probably avoid introducing an option for uppercasing UUIDs in the new `String.init` (and thus not have its `uppercase` parameter).

---

<div class="post-metadata">

**Author:** ![erithacus](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/erithacus/32/20377_2.png) [@erithacus](https://forums.swift.org/u/erithacus)\
**Post date:** [March 22, 2026, 1:41pm UTC](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427/41 "2026-03-22T13:41:51Z")

</div>

Makes sense to me

[Previous page](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427.md?page=1)

[Next page](https://forums.swift.org/t/pitch-uuid-v7-other-improvements/85427.md?page=3)
