---
title: ByteCountFormatStyle
framework: foundation
role: symbol
role_heading: Structure
path: foundation/bytecountformatstyle
---

# ByteCountFormatStyle

A format style that provides string representations of byte counts.

## Declaration

```swift
struct ByteCountFormatStyle
```

## Overview

Overview The following example creates an Int representing 1,024 bytes, and then formats it as an expression of memory storage, with the default byte count format style. let count: Int64 = 1024 let formatted = count.formatted(.byteCount(style: .memory)) // "1 kB" You can also customize a byte count format style, and use this to format one or more Int64 instances. The following example creates a format style to only use kilobyte units, and to spell out the exact byte count of the measurement. let style = ByteCountFormatStyle(style: .memory,                                                                   allowedUnits: [.kb],                                  spellsOutZero: true,                                  includesActualByteCount: false,                                  locale: Locale(identifier: "en_US")) let counts: [Int64] = [0, 1024, 2048, 4096, 8192, 16384, 32768, 65536] let formatted = counts.map ( {style.format($0) } ) // ["Zero kB", "1 kB", "2 kB", "4 kB", "8 kB", "16 kB", "32 kB", "64 kB"]

## Topics

### Creating a byte count style

- [init(style:allowedUnits:spellsOutZero:includesActualByteCount:locale:)](foundation/bytecountformatstyle/init(style:allowedunits:spellsoutzero:includesactualbytecount:locale:).md)
- [ByteCountFormatStyle.Units](foundation/bytecountformatstyle/units.md)

### Formatting byte count values

- [format(_:)](foundation/bytecountformatstyle/format(_:).md)

### Customizing style behavior

- [style](foundation/bytecountformatstyle/style-swift.property.md)
- [ByteCountFormatStyle.Style](foundation/bytecountformatstyle/style-swift.enum.md)

### Accessing style properties

- [allowedUnits](foundation/bytecountformatstyle/allowedunits.md)
- [ByteCountFormatStyle.Units](foundation/bytecountformatstyle/units.md)
- [spellsOutZero](foundation/bytecountformatstyle/spellsoutzero.md)
- [includesActualByteCount](foundation/bytecountformatstyle/includesactualbytecount.md)
- [locale](foundation/bytecountformatstyle/locale.md)

### Modifying style locale

- [locale(_:)](foundation/bytecountformatstyle/locale(_:).md)

### Creating attributed strings

- [attributed](foundation/bytecountformatstyle/attributed-swift.property.md)
- [ByteCountFormatStyle.Attributed](foundation/bytecountformatstyle/attributed-swift.struct.md)

## Relationships

### Conforms To

- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [Equatable](swift/equatable.md)
- [FormatStyle](foundation/formatstyle.md)
- [Hashable](swift/hashable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Applying byte-count styles

- [byteCount(style:allowedUnits:spellsOutZero:includesActualByteCount:)](foundation/formatstyle/bytecount(style:allowedunits:spellsoutzero:includesactualbytecount:)-59ep0.md)
- [byteCount(style:allowedUnits:spellsOutZero:includesActualByteCount:)](foundation/formatstyle/bytecount(style:allowedunits:spellsoutzero:includesactualbytecount:)-ev0u.md)
- [Measurement.FormatStyle.ByteCount](foundation/measurement/formatstyle/bytecount.md)
