---
title: ParseStrategy
framework: foundation
role: symbol
role_heading: Protocol
path: foundation/parsestrategy
---

# ParseStrategy

A type that parses an input representation, such as a formatted string, into a provided data type.

## Declaration

```swift
protocol ParseStrategy : Decodable, Encodable, Hashable
```

## Overview

Overview A ParseStrategy allows you to convert a formatted representation into a data type, using one of two approaches: Initialize the data type by calling an initializer of that type that takes a formatted instance and a parse strategy as parameters. For example, you can create a Decimal from a formatted string with the initializer init(_:format:lenient:). Create a parse strategy and call its parse(_:) method on one or more formatted instances. ParseStrategy is closely related to FormatStyle, which provides the opposite conversion: from data type to formatted representation. To use a parse strategy, you create a FormatStyle to define the representation you expect, then access the style’s parseStrategy property to get a strategy instance. The following example creates a Decimal.FormatStyle.Currency format style that uses US dollars and US English number-formatting conventions. It then creates a Decimal instance by providing a formatted string to parse and the format style’s parseStrategy. let style = Decimal.FormatStyle.Currency(code: "USD",                                          locale: Locale(identifier: "en_US")) let parsed = try? Decimal("$12,345.67",                            strategy: style.parseStrategy) // 12345.67

## Topics

### Performing parsing

- [parse(_:)](foundation/parsestrategy/parse(_:).md)

### Commonly-used parsers

- [fixed(format:timeZone:locale:)](foundation/parsestrategy/fixed(format:timezone:locale:).md)
- [url](foundation/parsestrategy/url.md)
- [name](foundation/parsestrategy/name.md)

### Commonly-used format styles

- [dateTime](foundation/parsestrategy/datetime.md)

### Supporting types

- [ParseInput](foundation/parsestrategy/parseinput.md)
- [ParseOutput](foundation/parsestrategy/parseoutput.md)

### Type Properties

- [http](foundation/parsestrategy/http-5mpzc.md)
- [http](foundation/parsestrategy/http-6hyig.md)
- [iso8601](foundation/parsestrategy/iso8601-69scf.md)
- [iso8601](foundation/parsestrategy/iso8601-8z0au.md)

## Relationships

### Inherits From

- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)

### Conforming Types

- [Date.FormatStyle](foundation/date/formatstyle.md)
- [Date.HTTPFormatStyle](foundation/date/httpformatstyle.md)
- [Date.ISO8601FormatStyle](foundation/date/iso8601formatstyle.md)
- [Date.ParseStrategy](foundation/date/parsestrategy.md)
- [DateComponents.HTTPFormatStyle](foundation/datecomponents/httpformatstyle.md)
- [DateComponents.ISO8601FormatStyle](foundation/datecomponents/iso8601formatstyle.md)
- [Decimal.ParseStrategy](foundation/decimal/parsestrategy.md)
- [FloatingPointParseStrategy](foundation/floatingpointparsestrategy.md)
- [IntegerParseStrategy](foundation/integerparsestrategy.md)
- [PersonNameComponents.ParseStrategy](foundation/personnamecomponents/parsestrategy.md)
- [URL.ParseStrategy](foundation/url/parsestrategy.md)

## See Also

### Data parsing in Swift

- [ParseableFormatStyle](foundation/parseableformatstyle.md)
- [IntegerParseStrategy](foundation/integerparsestrategy.md)
- [FloatingPointParseStrategy](foundation/floatingpointparsestrategy.md)
- [Decimal.ParseStrategy](foundation/decimal/parsestrategy.md)
