---
title: encode()
framework: realitykit
role: symbol
role_heading: Instance Method
platforms: [iOS 27.0+, iPadOS 27.0+, tvOS 27.0+, visionOS 27.0+]
path: realitykit/shadergraph/encode()
---

# encode()

Encodes the graph into a binary representation.

## Declaration

```swift
final func encode() throws -> Data
```

## Discussion

Discussion The resulting data can be stored to disk or passed across a process boundary, and later restored with init(from:). note: If the graph cannot be serialized.
