Bytes class

An immutable object representing an array of bytes.

Signature:

exportdeclareclassBytes

Methods

MethodModifiersDescription
fromBase64String(base64)staticCreates a newBytes object from the given Base64 string, converting it to bytes.
fromJSON(json)staticBuilds aBytes instance from a JSON object created byBytes.toJSON().
fromUint8Array(array)staticCreates a newBytes object from the given Uint8Array.
isEqual(other)Returns true if thisBytes object is equal to the provided one.
toBase64()Returns the underlying bytes as a Base64-encoded string.
toJSON()Returns a JSON-serializable representation of thisBytes instance.
toString()Returns a string representation of theBytes object.
toUint8Array()Returns the underlying bytes in a newUint8Array.

Bytes.fromBase64String()

Creates a newBytes object from the given Base64 string, converting it to bytes.

Signature:

staticfromBase64String(base64:string):Bytes;

Parameters

ParameterTypeDescription
base64stringThe Base64 string used to create theBytes object.

Returns:

Bytes

Bytes.fromJSON()

Builds aBytes instance from a JSON object created byBytes.toJSON().

Signature:

staticfromJSON(json:object):Bytes;

Parameters

ParameterTypeDescription
jsonobjecta JSON object represention of aBytes instance

Returns:

Bytes

an instance ofBytes if the JSON object could be parsed. Throws aFirestoreError if an error occurs.

Bytes.fromUint8Array()

Creates a newBytes object from the given Uint8Array.

Signature:

staticfromUint8Array(array:Uint8Array):Bytes;

Parameters

ParameterTypeDescription
arrayUint8ArrayThe Uint8Array used to create theBytes object.

Returns:

Bytes

Bytes.isEqual()

Returns true if thisBytes object is equal to the provided one.

Signature:

isEqual(other:Bytes):boolean;

Parameters

ParameterTypeDescription
otherBytesTheBytes object to compare against.

Returns:

boolean

true if thisBytes object is equal to the provided one.

Bytes.toBase64()

Returns the underlying bytes as a Base64-encoded string.

Signature:

toBase64():string;

Returns:

string

The Base64-encoded string created from theBytes object.

Bytes.toJSON()

Returns a JSON-serializable representation of thisBytes instance.

Signature:

toJSON():object;

Returns:

object

a JSON representation of this object.

Bytes.toString()

Returns a string representation of theBytes object.

Signature:

toString():string;

Returns:

string

A string representation of theBytes object.

Bytes.toUint8Array()

Returns the underlying bytes in a newUint8Array.

Signature:

toUint8Array():Uint8Array;

Returns:

Uint8Array

The Uint8Array created from theBytes object.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-06-30 UTC.