---
title: NumberFormatter
framework: foundation
role: symbol
role_heading: Class
path: foundation/numberformatter
---

# NumberFormatter

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

## Declaration

```swift
class NumberFormatter
```

## Overview

Overview Instances of NumberFormatter format the textual representation of cells that contain NSNumber objects and convert textual representations of numeric values into NSNumber objects. The representation encompasses integers, floats, and doubles; floats and doubles can be formatted to a specified decimal position. NumberFormatter objects can also impose ranges on the numeric values cells can accept. tip: In Swift, you can use IntegerFormatStyle, FloatingPointFormatStyle, or Decimal.FormatStyle rather than NumberFormatter. The FormatStyle API offers a declarative idiom for customizing the formatting of various types. Also, Foundation caches identical FormatStyle instances, so you don’t need to pass them around your app, or risk wasting memory with duplicate formatters. Significant Digits and Fraction Digits The NumberFormatter class provides flexible options for displaying non-zero fractional parts of numbers. If you set the usesSignificantDigits property to true, you can configure NumberFormatter to display significant digits using the minimumSignificantDigits and maximumSignificantDigits properties. If usesSignificantDigits is false, these properties are ignored. See Configuring Significant Digits. Otherwise, you can configure the minimum and maximum number of integer and fraction digits, or the numbers before and after the decimal separator, respectively, using the minimumIntegerDigits, maximumIntegerDigits, minimumFractionDigits, and maximumFractionDigits properties. See Configuring Integer and Fraction Digits. Thread Safety On iOS 7 and later NumberFormatter is thread-safe. In macOS 10.9 and later NumberFormatter is thread-safe so long as you are using the modern behavior in a 64-bit app. On earlier versions of the operating system, or when using the legacy formatter behavior or running in 32-bit in macOS, NumberFormatter is not thread-safe, and you therefore must not mutate a number formatter simultaneously from multiple threads.

## Topics

### Configuring Formatter Behavior and Style

- [formatterBehavior](foundation/numberformatter/formatterbehavior.md)
- [setDefaultFormatterBehavior(_:)](foundation/numberformatter/setdefaultformatterbehavior(_:).md)
- [defaultFormatterBehavior()](foundation/numberformatter/defaultformatterbehavior().md)
- [numberStyle](foundation/numberformatter/numberstyle.md)
- [generatesDecimalNumbers](foundation/numberformatter/generatesdecimalnumbers.md)

### Converting Between Numbers and Strings

- [getObjectValue(_:for:range:)](foundation/numberformatter/getobjectvalue(_:for:range:).md)
- [number(from:)](foundation/numberformatter/number(from:).md)
- [string(from:)](foundation/numberformatter/string(from:).md)
- [localizedString(from:number:)](foundation/numberformatter/localizedstring(from:number:).md)

### Managing Localization of Numbers

- [localizesFormat](foundation/numberformatter/localizesformat.md)
- [locale](foundation/numberformatter/locale.md)

### Configuring Rounding Behavior

- [roundingBehavior](foundation/numberformatter/roundingbehavior.md)
- [NSDecimalNumberHandler](foundation/nsdecimalnumberhandler.md)
- [roundingIncrement](foundation/numberformatter/roundingincrement.md)
- [roundingMode](foundation/numberformatter/roundingmode-swift.property.md)

### Configuring Integer and Fraction Digits

- [minimumIntegerDigits](foundation/numberformatter/minimumintegerdigits.md)
- [maximumIntegerDigits](foundation/numberformatter/maximumintegerdigits.md)
- [minimumFractionDigits](foundation/numberformatter/minimumfractiondigits.md)
- [maximumFractionDigits](foundation/numberformatter/maximumfractiondigits.md)

### Configuring Significant Digits

- [usesSignificantDigits](foundation/numberformatter/usessignificantdigits.md)
- [minimumSignificantDigits](foundation/numberformatter/minimumsignificantdigits.md)
- [maximumSignificantDigits](foundation/numberformatter/maximumsignificantdigits.md)

### Configuring Numeric Formats

- [format](foundation/numberformatter/format.md)
- [formattingContext](foundation/numberformatter/formattingcontext.md)
- [formatWidth](foundation/numberformatter/formatwidth.md)
- [negativeFormat](foundation/numberformatter/negativeformat.md)
- [positiveFormat](foundation/numberformatter/positiveformat.md)
- [multiplier](foundation/numberformatter/multiplier.md)

### Configuring Numeric Symbols

- [percentSymbol](foundation/numberformatter/percentsymbol.md)
- [perMillSymbol](foundation/numberformatter/permillsymbol.md)
- [minusSign](foundation/numberformatter/minussign.md)
- [plusSign](foundation/numberformatter/plussign.md)
- [exponentSymbol](foundation/numberformatter/exponentsymbol.md)
- [zeroSymbol](foundation/numberformatter/zerosymbol.md)
- [nilSymbol](foundation/numberformatter/nilsymbol.md)
- [notANumberSymbol](foundation/numberformatter/notanumbersymbol.md)
- [negativeInfinitySymbol](foundation/numberformatter/negativeinfinitysymbol.md)
- [positiveInfinitySymbol](foundation/numberformatter/positiveinfinitysymbol.md)

### Configuring the Format of Currency

- [currencySymbol](foundation/numberformatter/currencysymbol.md)
- [currencyCode](foundation/numberformatter/currencycode.md)
- [internationalCurrencySymbol](foundation/numberformatter/internationalcurrencysymbol.md)
- [currencyGroupingSeparator](foundation/numberformatter/currencygroupingseparator.md)

### Configuring Numeric Prefixes and Suffixes

- [positivePrefix](foundation/numberformatter/positiveprefix.md)
- [positiveSuffix](foundation/numberformatter/positivesuffix.md)
- [negativePrefix](foundation/numberformatter/negativeprefix.md)
- [negativeSuffix](foundation/numberformatter/negativesuffix.md)

### Configuring the Display of Numeric Values

- [textAttributesForNegativeValues](foundation/numberformatter/textattributesfornegativevalues.md)
- [textAttributesForPositiveValues](foundation/numberformatter/textattributesforpositivevalues.md)
- [attributedStringForZero](foundation/numberformatter/attributedstringforzero.md)
- [textAttributesForZero](foundation/numberformatter/textattributesforzero.md)
- [attributedStringForNil](foundation/numberformatter/attributedstringfornil.md)
- [textAttributesForNil](foundation/numberformatter/textattributesfornil.md)
- [attributedStringForNotANumber](foundation/numberformatter/attributedstringfornotanumber.md)
- [textAttributesForNotANumber](foundation/numberformatter/textattributesfornotanumber.md)
- [textAttributesForPositiveInfinity](foundation/numberformatter/textattributesforpositiveinfinity.md)
- [textAttributesForNegativeInfinity](foundation/numberformatter/textattributesfornegativeinfinity.md)

### Configuring Separators and Grouping Size

- [groupingSeparator](foundation/numberformatter/groupingseparator.md)
- [usesGroupingSeparator](foundation/numberformatter/usesgroupingseparator.md)
- [thousandSeparator](foundation/numberformatter/thousandseparator.md)
- [hasThousandSeparators](foundation/numberformatter/hasthousandseparators.md)
- [decimalSeparator](foundation/numberformatter/decimalseparator.md)
- [alwaysShowsDecimalSeparator](foundation/numberformatter/alwaysshowsdecimalseparator.md)
- [currencyDecimalSeparator](foundation/numberformatter/currencydecimalseparator.md)
- [groupingSize](foundation/numberformatter/groupingsize.md)
- [secondaryGroupingSize](foundation/numberformatter/secondarygroupingsize.md)

### Managing the Padding of Numbers

- [paddingCharacter](foundation/numberformatter/paddingcharacter.md)
- [paddingPosition](foundation/numberformatter/paddingposition.md)

### Managing Input and Output Attributes

- [allowsFloats](foundation/numberformatter/allowsfloats.md)
- [minimum](foundation/numberformatter/minimum.md)
- [maximum](foundation/numberformatter/maximum.md)

### Managing Leniency Behavior

- [isLenient](foundation/numberformatter/islenient.md)

### Managing the Validation of Partial Numeric Strings

- [isPartialStringValidationEnabled](foundation/numberformatter/ispartialstringvalidationenabled.md)

### Constants

- [NumberFormatter.Style](foundation/numberformatter/style.md)
- [NumberFormatter.Behavior](foundation/numberformatter/behavior.md)
- [NumberFormatter.PadPosition](foundation/numberformatter/padposition.md)
- [NumberFormatter.RoundingMode](foundation/numberformatter/roundingmode-swift.enum.md)

### Instance Properties

- [minimumGroupingDigits](foundation/numberformatter/minimumgroupingdigits.md)

## Relationships

### Inherits From

- [Formatter](foundation/formatter.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
