<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Combine",
  "identifier" : "/documentation/Combine/Publishers/Encode",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine10PublishersO6EncodeV"
  },
  "title" : "Publishers.Encode"
}
-->

# Publishers.Encode

A publisher that encodes elements received from an upstream publisher, using a given encoder.

```
struct Encode<Upstream, Coder> where Upstream : Publisher, Coder : TopLevelEncoder, Upstream.Output : Encodable
```

## Topics

### Creating a encode publisher

[`init(upstream:encoder:)`](/documentation/Combine/Publishers/Encode/init(upstream:encoder:))

Creates a publisher that decodes elements received from an upstream publisher, using a given decoder.

### Declaring supporting types

[`Publishers.Encode.Output`](/documentation/Combine/Publishers/Encode/Output)

The kind of values published by this publisher.

[`Publishers.Encode.Failure`](/documentation/Combine/Publishers/Encode/Failure)

The kind of errors this publisher might publish.

### Inspecting publisher properties

[`upstream`](/documentation/Combine/Publishers/Encode/upstream)



---

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)