| MQTT 5 introduces the Payload Format Indicator and Content Type as optional properties in CONNECT and PUBLISH packets. The Payload Format Indicator specifies whether the payload is an unspecified byte stream (0) or UTF-8 encoded (1), while the Content Type uses a UTF-8 string (typically a MIME type) to describe the payload's nature. Together, these MQTT 5 features enable transparent payload description, efficient pre-parsing, and improved interoperability across large-scale systems. Who is this blog for: MQTT implementers, IoT engineers, and solution architects working with MQTT 5 protocol implementations. |
|---|
Welcome to Part 8 of our MQTT 5 Essentials series. In Part 7, we explored shared subscriptions. In this article, we will focus on Payload Format Indicators, which specify the message content type, ensuring easier, more efficient parsing and interoperability between systems.
What is Payload Format Indicator in MQTT?
The Payload Format Indicator is a fundamental component of any MQTT packet that houses a payload. This includes a CONNECT packet encapsulating a WILL message or a PUBLISH packet. This optional byte value has two possible settings: a 0 indicates an “unspecified byte stream” while a 1 represents a “UTF-8 encoded payload.” When the Payload Format Indicator isn’t provided, it automatically defaults to 0.

MQTT Content Type
Similar to the Payload Format Indicator, the Content Type is also optional and can be incorporated in a CONNECT containing a WILL message or any PUBLISH packet. The value for the Content Type must be a UTF-8 encoded string that identifies the payload’s nature. When the Payload Format Indicator is set to 1, ideally, you should have a MIME content type descriptor (though it’s not a hard requirement). A valid UTF-8 String is all you need.

Why Describe the Payload Format?
The combined use of Payload Format Indicator and Content Type facilitates a transparent description of the payload content for any application message. This ability sets the stage for creating and defining industry-wide MQTT standards for varied payload formats. MQTT protocol experts view this standardization as the protocol’s natural progression.

Having the payload content description in the headers can prove incredibly beneficial in individual deployments. It ensures every message is correctly processed without delving into the payload itself. Depending on the content type, different messages within a system may need various parsing methods. Moreover, in certain instances, message persistence could hinge on the payload’s specific type. As the content-type definitions hinge on user design, the potential applications of this feature appear boundless.
Summing It Up
The Payload Format Indicator discerns whether a payload is an undefined byte array or a UTF-8 encoded message. When dealing with UTF-8 encoded messages, the sender can use the content type to specify the payload’s nature.
These features set the stage for transparent payload content definitions across large-scale systems and, potentially, entire industries. As the need for pre-parsing actual payloads diminishes, proper message processing can considerably enhance scalability.
Although it’s anticipated that most users will rely on known MIME types to describe the content, they can also use arbitrary UTF-8 Strings.
As we continue to explore all the features of MQTT 5, the next article will cover the Request - Response Pattern.
Sign up for our newsletter to get regular updates. Subscribe to our RSS feed here to stay updated. We encourage you to visit our MQTT Glossary for an in-depth understanding of the essential MQTT terminologies. It will equip you with the necessary vocabulary to grasp the complexities of MQTT and its various versions. Watch the video below that complements the concepts discussed in this article.
