---
title: "encode(to:configuration:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/encodablewithconfiguration/encode(to:configuration:)"
---

# encode(to:configuration:)

Encodes the value into the specified encoder with help from the provided configuration.

## Declaration

```swift
func encode(to encoder: any Encoder, configuration: Self.EncodingConfiguration) throws
```

## Parameters

- `encoder`: The encoder to write data to.
- `configuration`: An encoding configuration instance that provides additional information necessary for encoding.
