---
schema_version: "1"
id: 08b83720b751fb370cc4b59cd17b557af90d1b982d5a87a75fc2b7ff0a87c317
title: TO_HEX
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/scalar-func/string-func/to-hex.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/to-hex.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 86b1cf4eec340168dea6eae07d3c7b4bc1c1b6ebd3812a82a73e9fd821f2fed9
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `TO_HEX`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Converts data to its equivalent hexadecimal representation.

## Syntax

```sql
to_hex(<data>)
```

## Arguments

### Required

- `<data>`: The data to encode (int, bigint, or bytea).

## Returns

Returns a text value containing the hexadecimal representation of the data.

## Considerations

- Output is lowercase hexadecimal without a '0x' prefix.

## Examples

### Convert to Hex

Encode an integer to hexadecimal.

```sql
SELECT to_hex(2147483647) AS result;
```

Returns `'7fffffff'`.

## Related Documentation

- [String Types](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/string.md)
