---
url: /en/docs/fields/uuid.md
description: >-
  Generate read-only universally unique identifiers in Sveltia CMS
  automatically.
---

# UUID Field

The UUID field type provides a read-only field that automatically generates and displays a Universally Unique Identifier (UUID). It’s useful for uniquely identifying entries within the CMS.

## User Interface

### Editor

Read-only display of a [UUID](https://developer.mozilla.org/en-US/docs/Glossary/UUID) (Universally Unique Identifier) value. The UUID is automatically generated when a new entry is created and can’t be modified by default, because the [`readonly`](/en/docs/fields#readonly) option defaults to `true` for this field type. Set it to `false` to make the value editable.

### Preview

A read-only view of the UUID value.

## Data Type

A string representing a UUID in the standard 36-character format (e.g., `df733d7e-d2f7-4e4f-8f27-803046b64040`). Alphabetic characters are in lowercase.

If `use_b32_encoding` is set to true, the UUID will be represented in a 26-character lowercase [Base32](https://en.wikipedia.org/wiki/Base32) format (e.g., `c5t6kx3m6n7g4y2z2a5b7c3d4e`).

## Data Validation

No specific data validation is applied to the UUID field, as its value is automatically generated.

## Options

In addition to the [common field options](/en/docs/fields#common-options), the UUID field supports the following options:

### Required Options

#### `widget`

* **Type**: `string`
* **Default**: `string`

Must be set to `uuid`.

### Optional Options

::: warning Deprecation Notice

The `read_only` option has been deprecated in favor of the `readonly` common field option. The `read_only` option will be removed in Sveltia CMS v1.0.0. If you are upgrading from an older version, update your configuration accordingly.

:::

#### `default`

* **Type**: `string`
* **Default**: A newly generated UUID

The default value for the field. If not provided, a new UUID will be generated when the entry is created.

#### `prefix`

* **Type**: `string`
* **Default**: `""`

A string prefix to prepend to the generated UUID. Useful for adding context or categorization to the UUID.

#### `use_b32_encoding`

* **Type**: `boolean`
* **Default**: `false`

Whether to use Base32 encoding for the UUID. If set to `true`, the UUID will be represented in a 26-character lowercase Base32 format instead of the standard 36-character format.

## Examples

### Basic UUID Field

This example demonstrates a basic UUID field that generates a standard UUID.

::: code-group

```yaml [YAML]
- name: product_id
  label: Product ID
  widget: uuid
```

```toml [TOML]
[[fields]]
name = "product_id"
label = "Product ID"
widget = "uuid"
```

```json [JSON]
{
  "name": "product_id",
  "label": "Product ID",
  "widget": "uuid"
}
```

```js [JavaScript]
{
  name: 'product_id',
  label: 'Product ID',
  widget: 'uuid',
}
```

:::

Output example:

::: code-group

```yaml [YAML]
product_id: df733d7e-d2f7-4e4f-8f27-803046b64040
```

```toml [TOML]
product_id = "df733d7e-d2f7-4e4f-8f27-803046b64040"
```

```json [JSON]
{
  "product_id": "df733d7e-d2f7-4e4f-8f27-803046b64040"
}
```

:::

### UUID Field with Prefix and Base32 Encoding

This example demonstrates a UUID field that includes a prefix and uses Base32 encoding.

::: code-group

```yaml [YAML]
- name: order_id
  label: Order ID
  widget: uuid
  prefix: ORD-
  use_b32_encoding: true
```

```toml [TOML]
[[fields]]
name = "order_id"
label = "Order ID"
widget = "uuid"
prefix = "ORD-"
use_b32_encoding = true
```

```json [JSON]
{
  "name": "order_id",
  "label": "Order ID",
  "widget": "uuid",
  "prefix": "ORD-",
  "use_b32_encoding": true
}
```

```js [JavaScript]
{
  name: 'order_id',
  label: 'Order ID',
  widget: 'uuid',
  prefix: 'ORD-',
  use_b32_encoding: true,
}
```

:::

Output example:

::: code-group

```yaml [YAML]
order_id: ORD-c5t6kx3m6n7g4y2z2a5b7c3d4e
```

```toml [TOML]
order_id = "ORD-c5t6kx3m6n7g4y2z2a5b7c3d4e"
```

```json [JSON]
{
  "order_id": "ORD-c5t6kx3m6n7g4y2z2a5b7c3d4e"
}
```

:::
