---
title: "encode(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/propertylistencoder/encode(_:)"
---

# encode(_:)

Returns a property list that represents an encoded version of the value you supply.

## Declaration

```swift
func encode<Value>(_ value: Value) throws -> Data where Value : Encodable
```

## Parameters

- `value`: The value to encode as a property list.

## Discussion

Discussion If there’s a problem encoding the value you supply, this method throws an error based on the type of problem: The value fails to encode, or contains a nested value that fails to encode—this method throws the corresponding error. The value can’t be encoded as a property list—this method throws the EncodingError.invalidValue(_:_:) error.

## See Also

### Encoding

- [init()](foundation/propertylistencoder/init().md)
- [encode(_:configuration:)](foundation/propertylistencoder/encode(_:configuration:)-4biuh.md)
- [encode(_:configuration:)](foundation/propertylistencoder/encode(_:configuration:)-5ee8q.md)
