NFC Data Exchange Format (NDEF)

NDEF is a standardized data format specification by the NFC Forum which is used to describe how a set of actions are to be encoded onto a NFC tag or to be exchanged between two active NFC devices. The vast majority of NFC enabled devices (readers, phones, tablets…) support reading NDEF messages from NFC tags. All NDEF action types can be encoded onto all NFC chip types and NFC readers; however due to data size requirements and NFC chip type memory limitations it’s best to choose an NFC chip knowing the type of data you will be encoding.

Formatting

All NFC Forum compliant NFC chips must be able to be formatted as NDEF. By formatting an NFC chip as NDEF, applications know to interpret the NFC chip’s user memory as being an NDEF message. The process to format an NFC chip involves writing a specific data structure to the NFC chip’s memory in a OTP (one time programable) section. Since this memory location is OTP, the process of formatting an NFC tag is a permanent operation. Some NFC chip types, such as the NXP NTAG21x series, come pre-NDEF formatted so they can only ever store NDEF data; other NFC chip types are not pre-NDEF formatted but can be, which is called “NDEF Formattable”.

Structure

NDEF is comprised of an NDEF Message with 1+ NDEF record types.

At a basic level, an NDEF record contains two components:

  • Record Type: Used to contextualize the payload data; one of the defined NDEF record types
  • Payload: The data of the record; formatted as defined by the specific NDEF record type

Together these two components represent the action to be taken by the devices when the NFC tag is touched. NDEF supports a fairly limited set of actions. More complex actions can be implemented with customized software running on the touching device. The benefit of using NDEF is that you don’t need to have custom software running on the touching device. Note that since the action is occurring on the touching device without any custom code or without any server side integration, no analytic data is captured about the usage of the NFC tag. Multiple records can be written to an NFC tag; however many software applications only act on the 1st record.

Multiple Records

An NDEF message can contain more than one NDEF record. In many systems, the first NDEF record in a message is the most important and indicates the default action that will be performed on the device. Subsequent NDEF records are used to support the first record. This can either be for additional “hidden” data, or to tie the NFC tag to a specific software application; an Android Application Record is a good example of this as it’s often the 2nd or last NDEF record in the message. Many apps are built to ignore subsequent records within the message.

In general, only use multiple NDEF records within a message if you have a specific reason to do so and understand the purpose and limitations of it.