Skip to main content

util.randomBytes()

Synchronously generates random bytes as a string. Size: integer 0..65536 bytes before encoding. Invalid types/options throw TypeError; size/range throws RangeError.

Signature

Example

See all util methods or runtime basics.
Last modified on November 8, 2026