<!--
{
  "documentType" : "article",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/data-formatting",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Data Formatting"
}
-->

# Data Formatting

Convert numbers, dates, measurements, and other values to and from locale-aware string representations.

## Discussion

Foundation supports two approaches for data formatting:

- When working in Swift, use `formatted` methods directly on the types you want to format, optionally using [`FormatStyle`](/documentation/Foundation/FormatStyle) and its subtypes to customize formatter output. This approach supports dates, integers, floating-point numbers, measurements, sequences, and person name components. Foundation caches identically-configured formatter instances internally, allowing you to focus on your app’s formatting needs.
- In Objective-C, create instances of [`Formatter`](/documentation/Foundation/Formatter) and its subtypes, and use the [`string(for:)`](/documentation/Foundation/Formatter/string(for:)) method to convert objects to formatted strings.

## Topics

### Essentials

[Building a Localized Food-Ordering App](/documentation/Foundation/building-a-localized-food-ordering-app)

Format, style, and localize your app’s text for use in multiple languages with string formatting, attributed strings, and automatic grammar agreement.

[Displaying Human-Friendly Content](/documentation/Foundation/displaying-human-friendly-content)

Convert data into readable strings or Swift objects using formatters.

### Data formatting in Swift

[Language Introspector](/documentation/Foundation/language-introspector)

Converts data into human-readable text using formatters and locales.

[`FormatStyle`](/documentation/Foundation/FormatStyle)

A type that converts a given data type into a representation in another type, such as a string.

[`IntegerFormatStyle`](/documentation/Foundation/IntegerFormatStyle)

A structure that converts between integer values and their textual representations.

[`FloatingPointFormatStyle`](/documentation/Foundation/FloatingPointFormatStyle)

A structure that converts between floating-point values and their textual representations.

[`Decimal.FormatStyle`](/documentation/Foundation/Decimal/FormatStyle)

A structure that converts between decimal values and their textual representations.

[`ListFormatStyle`](/documentation/Foundation/ListFormatStyle)

A type that formats lists of items with a separator and conjunction appropriate for a given locale.

[`StringStyle`](/documentation/Foundation/StringStyle)

[`URL.FormatStyle`](/documentation/Foundation/URL/FormatStyle)

A structure that converts between URL instances and their textual representations.

[`FormatStyleCapitalizationContext`](/documentation/Foundation/FormatStyleCapitalizationContext)

The capitalization formatting context used when formatting dates and times.

[Format Style Configurations](/documentation/Foundation/format-style-configurations)

Behaviors for traits like numeric precision, rounding, and scale, used for formatting and parsing numeric values.

### Data parsing in Swift

[`ParseableFormatStyle`](/documentation/Foundation/ParseableFormatStyle)

A type that can convert a given input data type into a representation in an output type.

[`ParseStrategy`](/documentation/Foundation/ParseStrategy)

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

[`IntegerParseStrategy`](/documentation/Foundation/IntegerParseStrategy)

A parse strategy for creating integer values from formatted strings.

[`FloatingPointParseStrategy`](/documentation/Foundation/FloatingPointParseStrategy)

A parse strategy for creating floating-point values from formatted strings.

[`Decimal.ParseStrategy`](/documentation/Foundation/Decimal/ParseStrategy)

A parse strategy for creating decimal values from formatted strings.

### Numbers and currency

[`NumberFormatter`](/documentation/Foundation/NumberFormatter)

A formatter that converts between numeric values and their textual representations.

### Names

[`PersonNameComponentsFormatter`](/documentation/Foundation/PersonNameComponentsFormatter)

A formatter that provides localized representations of the components of a person’s name.

[`PersonNameComponents`](/documentation/Foundation/PersonNameComponents)

The separate parts of a person’s name, allowing locale-aware formatting.

### Names

[`NSPersonNameComponents`](/documentation/Foundation/NSPersonNameComponents)

An object that manages the separate parts of a person’s name to allow locale-aware formatting.

### Dates and times

[`DateFormatter`](/documentation/Foundation/DateFormatter)

A formatter that converts between dates and their textual representations.

[`DateComponentsFormatter`](/documentation/Foundation/DateComponentsFormatter)

A formatter that creates string representations of quantities of time.

[`RelativeDateTimeFormatter`](/documentation/Foundation/RelativeDateTimeFormatter)

A formatter that creates locale-aware string representations of a relative date or time.

[`DateIntervalFormatter`](/documentation/Foundation/DateIntervalFormatter)

A formatter that creates string representations of time intervals.

[`ISO8601DateFormatter`](/documentation/Foundation/ISO8601DateFormatter)

A formatter that converts between dates and their ISO 8601 string representations.

### Data sizes

[`ByteCountFormatter`](/documentation/Foundation/ByteCountFormatter)

A formatter that converts a byte count value into a localized description that is formatted with the appropriate byte modifier (KB, MB, GB and so on).

### Measurements

[`MeasurementFormatter`](/documentation/Foundation/MeasurementFormatter)

A formatter that provides localized representations of units and measurements.

### Lists

[`ListFormatter`](/documentation/Foundation/ListFormatter)

An object that provides locale-correct formatting of a list of items using the appropriate separator and conjunction.

### Internationalization

[`Locale`](/documentation/Foundation/Locale)

Information about linguistic, cultural, and technological conventions for use in formatting data for presentation.

### Internationalization

[`NSLocale`](/documentation/Foundation/NSLocale)

Information about linguistic, cultural, and technological conventions for use in formatting data for presentation.

### Custom formatters

[`Formatter`](/documentation/Foundation/Formatter)

An abstract class that declares an interface for objects that create, interpret, and validate the textual representation of values.

### Automatic grammar agreement

[`InflectionRule`](/documentation/Foundation/InflectionRule)

A rule that affects how an attributed string performs automatic grammatical agreement.

[`Morphology`](/documentation/Foundation/Morphology)

A description of the grammatical properties of a string.

[`TermOfAddress`](/documentation/Foundation/TermOfAddress)

The type for representing grammatical gender in localized text.

[`InflectionConcept`](/documentation/Foundation/InflectionConcept)

An inflection method to use when localizing text.

[`Morphology.Pronoun`](/documentation/Foundation/Morphology/Pronoun)

A custom pronoun for referring to a third person.

[`NSInflectionRule`](/documentation/Foundation/NSInflectionRule)

A rule that affects how an attributed string performs automatic grammatical agreement.

[`NSInflectionRuleExplicit`](/documentation/Foundation/NSInflectionRuleExplicit)

An inflection rule that uses a morphology instance to determine how to inflect attribued strings.

[`NSMorphology`](/documentation/Foundation/NSMorphology)

A description of the grammatical properties of a string.

[`NSTermOfAddress`](/documentation/Foundation/NSTermOfAddress)

The type for representing grammatical gender in localized text.

[`NSMorphologyPronoun`](/documentation/Foundation/NSMorphologyPronoun)

A custom pronoun for referring to a third person.

### Deprecated

[`LengthFormatter`](/documentation/Foundation/LengthFormatter)

A formatter that provides localized descriptions of linear distances, such as length and height measurements.

[`MassFormatter`](/documentation/Foundation/MassFormatter)

A formatter that provides localized descriptions of mass and weight values.

[`EnergyFormatter`](/documentation/Foundation/EnergyFormatter)

A formatter that provides localized descriptions of energy values.



---

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)