---
title: JSONDecoder
framework: foundation
role: symbol
role_heading: Class
path: foundation/jsondecoder
---

# JSONDecoder

An object that decodes instances of a data type from JSON objects.

## Declaration

```swift
class JSONDecoder
```

## Overview

Overview The example below shows how to decode an instance of a simple GroceryProduct type from a JSON object. The type adopts Codable so that it’s decodable using a JSONDecoder instance. struct GroceryProduct: Codable {     var name: String     var points: Int     var description: String? }

let json = """ {     "name": "Durian",     "points": 600,     "description": "A fruit with a distinctive scent." } """.data(using: .utf8)!

let decoder = JSONDecoder() let product = try decoder.decode(GroceryProduct.self, from: json)

print(product.name) // Prints "Durian"

## Topics

### Creating a Decoder

- [init()](foundation/jsondecoder/init().md)

### Decoding

- [decode(_:from:)](foundation/jsondecoder/decode(_:from:).md)

### Customizing Decoding

- [keyDecodingStrategy](foundation/jsondecoder/keydecodingstrategy-swift.property.md)
- [JSONDecoder.KeyDecodingStrategy](foundation/jsondecoder/keydecodingstrategy-swift.enum.md)
- [userInfo](foundation/jsondecoder/userinfo.md)
- [allowsJSON5](foundation/jsondecoder/allowsjson5.md)
- [assumesTopLevelDictionary](foundation/jsondecoder/assumestopleveldictionary.md)

### Decoding Dates

- [dateDecodingStrategy](foundation/jsondecoder/datedecodingstrategy-swift.property.md)
- [JSONDecoder.DateDecodingStrategy](foundation/jsondecoder/datedecodingstrategy-swift.enum.md)

### Decoding Raw Data

- [dataDecodingStrategy](foundation/jsondecoder/datadecodingstrategy-swift.property.md)
- [JSONDecoder.DataDecodingStrategy](foundation/jsondecoder/datadecodingstrategy-swift.enum.md)

### Decoding Exceptional Numbers

- [nonConformingFloatDecodingStrategy](foundation/jsondecoder/nonconformingfloatdecodingstrategy-swift.property.md)
- [JSONDecoder.NonConformingFloatDecodingStrategy](foundation/jsondecoder/nonconformingfloatdecodingstrategy-swift.enum.md)

### Instance Methods

- [decode(_:from:configuration:)](foundation/jsondecoder/decode(_:from:configuration:)-22lge.md)
- [decode(_:from:configuration:)](foundation/jsondecoder/decode(_:from:configuration:)-xsq1.md)

## Relationships

### Conforms To

- [Copyable](swift/copyable.md)
- [Escapable](swift/escapable.md)
- [NetworkDecoder](network/networkdecoder.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [TopLevelDecoder](combine/topleveldecoder.md)

## See Also

### JSON

- [Using JSON with custom types](foundation/using-json-with-custom-types.md)
- [JSONEncoder](foundation/jsonencoder.md)
- [JSONSerialization](foundation/jsonserialization.md)
