<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/EncodableWithConfiguration/encode(to:configuration:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation26EncodableWithConfigurationP6encode2to13configurationys7Encoder_p_08EncodingD0QztKF"
  },
  "title" : "encode(to:configuration:)"
}
-->

# encode(to:configuration:)

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

```
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.

---

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)