Skip to content

MQTT Payload Format Description and Content Type – MQTT 5 Essentials Part 8

by Florian Raschbichler
6 min read

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.

The Payload Format Description is optional. It can have the values The Payload Format Description is optional. It can have the values "1" or "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.

For UTF-8 encoded strings Content Types can be defined.For UTF-8 encoded strings Content Types can be defined.

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.Payload Format Description allows pre-parsing without the need to open the payloadPayload Format Description allows pre-parsing without the need to open the payload

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.

Watch the Video

Chapters
  • 00:00 - Introduction to Payload Format Description in MQTT5
  • 00:44 - How Payload Format Description works in MQTT5
  • 01:44 - Why describe the Payload Format?
  • 02:58 - Announcing part 8: Request-Response Pattern in MQTT5

FAQs on MQTT Payload Format Description and Content Type

Florian Raschbichler

Florian serves as the head of the HiveMQ support team with years of first hand experience overcoming challenges in achieving reliable, scalable, and secure IoT messaging for enterprise customers.

  • Contact Florian Raschbichler via e-mail

Related content:

HiveMQ logo
Review HiveMQ on G2