Text Record

The NDEF Text Record is a well-known record type defined by the NFC Forum. It carries a UTF-8 or UTF-16 encoded text string with an associated IANA language code identifier.

class ndef.TextRecord(text='', language='en', encoding='UTF-8')

A TextRecord is initialized with the actual text content, an ISO/IANA language identifier, and the desired transfer encoding UTF-8 or UTF-16. Default values are empty text, language code ‘en’, and ‘UTF-8’ encoding.

  • text (str) – initial value for the text attribute, default ‘’
  • language (str) – initial value for the language attribute, default ‘en’
  • encoding (str) – initial value for the encoding attribute, default ‘UTF-8’

The Text Record type is urn:nfc:wkt:T.


Value of the NDEF Record ID field, an empty str if not set.


A bytes object containing the NDEF Record PAYLOAD encoded from the current attributes.


The decoded or set text string value.


The decoded or set IANA language code identifier.


The transfer encoding of the text string. Either ‘UTF-8’ or ‘UTF-16’.

>>> import ndef
>>> record = ndef.TextRecord("Hallo Welt", "de")
>>> octets = b''.join(ndef.message_encoder([record]))
>>> print(list(ndef.message_decoder(octets))[0])
NDEF Text Record ID '' Text 'Hallo Welt' Language 'de' Encoding 'UTF-8'