Skip to main content

Content Types

All messages in XMTP are encoded with a content type to ensure interoperability and consistency of experience across the network.

Message payloads are transported as simply a set of bytes. This means they can carry any content type that a developer would want to support, such as plaintext, JSON, or even non-text binary or media content.

The client interface allows new content types to be adopted and put to immediate use without going through a formal process. Clients may choose to adopt those content types if they wish to render those message types, but can also rely on fallback plaintext.

Two predefined content types come bundled with the client SDK:

  1., which defines a default TextCodec for plaintext content
  2., which defines an optional CompositeCodec for multiple content types in a single message

These content types were adopted through the XMTP Improvement Proposal process, which enables a framework for community members to propose standards and achieve consensus around their adoption.


Specify a content type to enable during client initialization. For example, to enable a fictional "number" type using xmtp-js:

// Adding support for a fictional `` content type
import { NumberCodec } from '@xmtp/xmtp-js'
const xmtp = Client.create(wallet, { codecs: [new NumberCodec()] })

Send a message using a specified content type and fallback plaintext. Using xmtp-js:

// Assuming NumberCodec can be used to encode numbers and is
// identified with ContentTypeNumber, we can use it as follows.
conversation.send(3.14, {
contentType: ContentTypeNumber,
contentFallback: '3.14'