rfid.wtf / WTF is RFID?
Deep diveHF · 13.56 MHz

NFC and NDEF

The data format that makes "tap a sticker, open a link" work on every phone.

NFC (Near Field Communication) is the phone-friendly corner of 13.56 MHz RFID. The NFC Forum took existing card standards like ISO 14443, ISO 15693 and FeliCa, and agreed on how phones should talk to all of them. Then it added one very useful thing: a common data format, so any phone can understand any tag.

That format is NDEF, the NFC Data Exchange Format. When you tap a sticker and a web page opens, that's NDEF.

Stickers, fobs, wristbands, cards: same flat coil, different plastic.
Stickers, fobs, wristbands, cards: same flat coil, different plastic.

#Messages and records

An NDEF message is a list of one or more records. Each record has:

  • a header byte: flags for "first record", "last record", "short record", plus a 3-bit TNF (type name format) that says how to read the type
  • a type, like U for a URL or T for text
  • a payload: the actual content

The record types you'll meet most:

Type What it holds What a phone does
U (URI) a URL, tel:, mailto:… opens it
T (Text) text plus a language code shows it
Sp (Smart Poster) a URI with a title and extras opens it, with a nicer prompt
media type, e.g. text/vcard a contact card offers to save the contact
Wi-Fi handover network name and password offers to join
Android app record an app's package name opens that app (Android)

Try building one. Type a URL and watch it turn into the exact bytes a tag stores:

The URI record has a neat trick: the first payload byte is a prefix code. 04 means https://, 03 means http:// and so on, which saves a few precious bytes on a tag that may only hold 144.

#Tag types

The NFC Forum defines five tag types, each a different underlying chip family. NDEF looks the same on all of them; only the plumbing differs.

Type Based on You know it as
Type 2 ISO 14443-A memory cards NTAG and MIFARE Ultralight stickers, the cheap common ones
Type 4 ISO 14443-4 smart cards DESFire, many "NFC cards"; NDEF lives in a file
Type 5 ISO 15693 ICODE tags, a bit more range
Type 3 FeliCa common in Japan
Type 1 ISO 14443-A (Topaz) old, rarely seen now
Into the weeds: Where the bytes actually sit on an NTAG

A Type 2 tag is memory in 4-byte pages. Page 3 is the capability container: E1 ("there's NDEF here"), a version byte, the NDEF area size in 8-byte units, and an access byte. NDEF starts at page 4, wrapped in a TLV: 03, a length, the message, then FE to say "done". That's the outer layer the builder above shows. On an NTAG213 the capability container is E1 10 12 00: 0x12 × 8 = 144 bytes of room.

#Writing your own

Blank NTAG stickers cost pennies, and any NFC phone can write them. Good first projects: a sticker by the door that opens your shopping list, a Wi-Fi tag for guests, or a contact card on the back of your badge.

With Your phone

NFC Tools writes URL, text, Wi-Fi and contact records, and its "Other" tab has the lock option. NXP TagInfo shows the raw NDEF and the capability container if you want to see the bytes for real.

Where next

Shows up in