In code
Generate a UUID in Kotlin
Kotlin reuses the JDK's java.util.UUID.
Kotlin example
Kotlin
import java.util.UUID
val id = UUID.randomUUID().toString()
No install? Use the tool or API
Here's a fresh version 4 UUID generated right now — copy it, or call the API from any language.
208d9bd1-5521-4864-a4db-b755170cb809
curl https://getuuid.sh/api/uuid