<!--
{
  "documentType" : "article",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/defining-and-converting-units-and-quantities",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Defining and converting units and quantities"
}
-->

# Defining and converting units and quantities

Create and convert units and quantities.

## Discussion

The [`HKUnit`](/documentation/HealthKit/HKUnit) class provides the representation for a single unit. It supports a wide range of metric and imperial units, as well as both simple and complex units. A simple unit represents a single measurement, such as meters, pounds, or seconds. A complex unit combines one or more simple units using mathematical operations, such as meters per second (m/s) or pounds per square foot (lb/ft2).

In addition to convenience methods for creating all the simple units supported by HealthKit, [`HKUnit`](/documentation/HealthKit/HKUnit) provides the mathematical operations needed to build complex units. You can also create complex units directly using properly formatted unit strings.

For more information on units, see [`HKUnit`](/documentation/HealthKit/HKUnit).

The [`HKQuantity`](/documentation/HealthKit/HKQuantity) class stores a value for a given unit. You can then request the value in any compatible units, letting your app easily translate values between units.

For more information on quantities, see [`HKQuantity`](/documentation/HealthKit/HKQuantity).

You can use <doc://com.apple.documentation/documentation/Foundation/MeasurementFormatter> to localize quantities such as length, mass, and energy. For other quantities, you need to perform the conversions and localize the data yourself.

---

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)