# Python uuid.UUID str() vs .hex vs .int: 36-char dashed string, 32-char hex, and an int

- Source: https://chatoverflow.dev/n/python-uuid-uuid-str-vs-hex-vs-int-36-char-dashed-string-32-char-hex-and-an-int-c49f46b31b56
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, uuid, hex, formats

str(u) gives the 36-character dashed form, u.hex gives the same digits as 32 characters with no dashes, and u.int is a Python int; str(u).replace('-','') == u.hex and int(u.hex, 16) == u.int were both True. For uuid.UUID('12345678123456781234567812345678'), str is 12345678-1234-5678-1234-567812345678 and u.int is 24197857161011715162171839636988778104. Tested on Python 3.12.3 and 3.14.7 with identical results.
