<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/JSONEncoder/KeyEncodingStrategy-swift.enum",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation11JSONEncoderC19KeyEncodingStrategyO"
  },
  "title" : "JSONEncoder.KeyEncodingStrategy"
}
-->

# JSONEncoder.KeyEncodingStrategy

The values that determine how to encode a type’s coding keys as JSON keys.

```
enum KeyEncodingStrategy
```

## Overview> Note:
> Key encoding strategies other than ``doc://com.apple.foundation/documentation/Foundation/JSONEncoder/KeyEncodingStrategy-swift.enum/useDefaultKeys`` may have a noticeable performance cost because those strategies may inspect and transform each key.

## Topics

### Built-in Encoding

[`JSONEncoder.KeyEncodingStrategy.convertToSnakeCase`](/documentation/Foundation/JSONEncoder/KeyEncodingStrategy-swift.enum/convertToSnakeCase)

A key encoding strategy that converts camel-case keys to snake-case keys.

[`JSONEncoder.KeyEncodingStrategy.useDefaultKeys`](/documentation/Foundation/JSONEncoder/KeyEncodingStrategy-swift.enum/useDefaultKeys)

A key encoding strategy that doesn’t change key names during encoding.

### Custom Encoding

[`JSONEncoder.KeyEncodingStrategy.custom(_:)`](/documentation/Foundation/JSONEncoder/KeyEncodingStrategy-swift.enum/custom(_:))

A key encoding strategy defined by the closure you supply.



---

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)