Documentation

Work with bytes types

A bytes type represents a sequence of byte values.

Type name: bytes

Bytes syntax

Flux does not provide a bytes literal syntax. Use the bytes() function to convert a string into bytes.

bytes(v: "hello")
// Returns [104 101 108 108 111]

Only string types can be converted to bytes.

Convert strings to bytes

Use bytes() or hex.bytes() to convert strings to bytes.

  • bytes(): Convert a string to bytes
  • hex.bytes(): Decode hexadecimal value and convert it to bytes.

Convert a hexadecimal string to bytes

import "contrib/bonitoo-io/hex"

hex.bytes(v: "FF5733")
// Returns [255 87 51] (bytes)

Include the string representation of bytes in a table

Use display() to return the string representation of bytes and include it as a column value. display() represents bytes types as a string of lowercase hexadecimal characters prefixed with 0x.

import "sampledata"

sampledata.string()
    |> map(fn: (r) => ({r with _value: display(v: bytes(v: r._value))}))

Output

tag_time_value (string)
t12021-01-01T00:00:00Z0x736d706c5f673971637a73
t12021-01-01T00:00:10Z0x736d706c5f306d6776396e
t12021-01-01T00:00:20Z0x736d706c5f706877363634
t12021-01-01T00:00:30Z0x736d706c5f6775767a7934
t12021-01-01T00:00:40Z0x736d706c5f357633636365
t12021-01-01T00:00:50Z0x736d706c5f7339666d6779
tag_time_value (string)
t22021-01-01T00:00:00Z0x736d706c5f623565696461
t22021-01-01T00:00:10Z0x736d706c5f6575346f7870
t22021-01-01T00:00:20Z0x736d706c5f356737747a34
t22021-01-01T00:00:30Z0x736d706c5f736f78317574
t22021-01-01T00:00:40Z0x736d706c5f77666d373537
t22021-01-01T00:00:50Z0x736d706c5f64746e326276

Was this page helpful?

Thank you for your feedback!


New in InfluxDB 3.5

Key enhancements in InfluxDB 3.5 and the InfluxDB 3 Explorer 1.3.

See the Blog Post

InfluxDB 3.5 is now available for both Core and Enterprise, introducing custom plugin repository support, enhanced operational visibility with queryable CLI parameters and manual node management, stronger security controls, and general performance improvements.

InfluxDB 3 Explorer 1.3 brings powerful new capabilities including Dashboards (beta) for saving and organizing your favorite queries, and cache querying for instant access to Last Value and Distinct Value caches—making Explorer a more comprehensive workspace for time series monitoring and analysis.

For more information, check out:

InfluxDB Docker latest tag changing to InfluxDB 3 Core

On November 3, 2025, the latest tag for InfluxDB Docker images will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments.

If using Docker to install and run InfluxDB, the latest tag will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments. For example, if using Docker to run InfluxDB v2, replace the latest version tag with a specific version tag in your Docker pull command–for example:

docker pull influxdb:2