Docs

stringToBytes

Converts a string to an array of bytes.

Example

import { stringToBytes } from "thirdweb/utils";
const bytes = stringToBytes("Hello, world!");
console.log(bytes); // Uint8Array(13) [ 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33 ]

Parameters

Returns

The array of bytes representing the string.