<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "CKToolJS",
  "identifier" : "/documentation/CKToolJS/CKToolDatabaseModule/toByteArray",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "CKTool JS"
    ],
    "preciseIdentifier" : "clm/CKToolDatabaseModule/toByteArray"
  },
  "title" : "toByteArray"
}
-->

# toByteArray

Converts a numeric array to a `ByteArray`.

```
static ByteArray toByteArray();
```

## Parameters

`value`

A numeric array to convert or validate.

## Return Value

If the value passes validation, this function returns a `ByteArray`; otherwise it throws `ValueNotByteArrayError`. A numeric array passes validation if every element of the array is an integer in the range 0 to 255, inclusive.

## Discussion

In TypeScript, `ByteArray` is a branded `Uint8Array` type. In JavaScript, it’s a `Uint8Array`.

```javascript
import { toByteArray } from "@apple/cktool.database";
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)