How do you write an NFC tag?
Writing an NFC tag means storing NDEF content on it: a web address, a Wi-Fi credential, a contact card. Any phone with NFC and a writing application can do it in a second. What deserves thought beforehand is what to store, how much fits, and whether to lock the tag afterwards.
What writing actually does
A tag is a small block of rewritable memory. Writing puts bytes into it, arranged according to a format called NDEF so that any compliant reader can make sense of them afterwards.
The operation itself takes a fraction of a second and needs nothing more than a phone held against the tag. What takes thought is everything around it: choosing what to store, checking it fits, and deciding whether the tag should ever be changed again.
What you can put on a tag
A web address is by far the most common, and for good reason: it is short, it works on both platforms, and the content it points at can be changed later without touching the tag.
Beyond that, a tag can hold a contact card, Wi-Fi credentials, a phone number, an email with a prefilled subject, geographic coordinates, plain text, or a custom payload only your own software understands. Each of these is a record type, and the type is what tells a phone what to do rather than merely what it holds.
What a tag cannot hold is anything large. There is no photograph, no document and no video, and the constraint is memory rather than speed.
How much fits
Less than the packaging says, always. Part of the memory describes the tag to readers, the NDEF container adds its own header, and each record costs bytes before its content starts.
For a typical consumer tag this leaves room for a URL and little else, which is exactly why the link and server pattern dominates. Store a short address on the tag, put everything else behind it, and you gain the ability to change the destination for a thousand tags without collecting any of them.
Formatting, and when you need it
Formatting writes the structure that lets a generic reader find content, rather than erasing anything in the way the word suggests. Most tags arrive pre formatted, which is why writing to a new tag usually works with no preliminary step.
When it does not, and a write fails with a complaint about the format, formatting first is the missing action.
Locking, the one step you cannot undo
A tag can be permanently locked so that its content can never be changed again. It is a genuine one way operation performed in software, with no physical trace and no recovery, and it sits as a checkbox next to the write button in most tools.
That placement causes a steady stream of accidents. Lock a tag for a public deployment where substitution is a real risk, and leave it unlocked everywhere else, because the ability to correct a mistake is worth more than the protection in most situations.
Before you lock anything
Verify what you wrote by reading the tag back. A write interrupted partway through can leave content that looks plausible and is not, and locking that state makes it permanent.
All guides in this section
- NDEF fundamentals
- Record types
- Formatting and preparing
- Locking and password protection
- Bulk writing and production
- Copying your own tags
NDEF fundamentals
- What is an NDEF message, and how is it built?
- How many records can one tag hold, and should it?
- What is TNF, and why does it change what happens on tap?
- In what order are multiple records acted on?
- Which NDEF records does iOS actually act on?
- How much tag memory does NDEF overhead consume?
- What happens when an NDEF message exceeds the tag?
- Can a tag hold data that is not NDEF?
- Writing and formatting a tag are not the same thing
- Does writing a tag erase what was on it?
Record types
- How do you write a URL to an NFC tag?
- Why are URL prefixes abbreviated on a tag?
- How do you write plain text, and who reads it?
- How do you write Wi-Fi credentials to a tag?
- Why does a Wi-Fi tag work on Android but not on iPhone?
- How do you write a contact card to a tag?
- Which record type should you choose for a business card?
- How do you write a phone number that triggers a call?
- How do you write an email with a prefilled subject?
- How do you write an SMS to a tag?
- How do you write geographic coordinates to a tag?
- How do you make a tag open a specific app?
- What is an Android Application Record?
- Can one tag carry more than one action?
Formatting and preparing
- Does a new tag need to be formatted before use?
- What does formatting an NFC tag actually do?
- How do you check how much free space a tag has?
- How do you erase an NFC tag?
- Can a tag be returned to its factory state?
- What can you configure on a tag besides its content?
- Can you prepare tags before you know the content?
- Why you should test a tag before deploying it
- How do you write to a tag already stuck to a surface?
Locking and password protection
- What does locking an NFC tag actually do?
- Can a locked NFC tag be unlocked?
- When should you lock a tag, and when should you not?
- Locking or password protection: which one do you need?
- How do you set a password on a tag, and what does it protect?
- Can you lock only part of a tag?
- Can a tag be protected from being read?
- What happens if you lose a tag password?
- Is a locked tag really safe from being overwritten?
- Should a public tag be locked before deployment?
Bulk writing and production
- How do you write hundreds of tags without doing it one by one?
- Can every tag in a batch carry a different URL?
- How do you keep track of which tag holds what?
- Should tags be written before or after being applied?
- How long does it take to write a batch of tags?
- What goes wrong when writing a large batch?
- How do you verify a batch was written correctly?
- How do you handle a tag that fails during a run?
- Factory encoded tags: when are they worth it?
Copying your own tags
- How do you copy the content of one tag to another?
- How do you back up a tag before overwriting it?
- Why can a copied tag behave differently from the original?
- Can you copy a tag onto a different chip type?
- Can you copy a tag whose UID matters?
- Why does copying a transport card not work?
- How do you replace a damaged tag without changing anything else?
- How do you migrate a deployment to new tags?
Frequently asked questions
Do I need an application to write a tag?
Yes. Neither mobile operating system exposes writing in its own interface, so a tool is required for writing, formatting and locking. Reading common content works without one.
Can I rewrite a tag as many times as I want?
For practical purposes yes, since the write cycle limit is far beyond what any normal deployment reaches. The exception is a locked tag, which cannot be rewritten at all.
Will a tag I write work on both Android and iPhone?
A web address will. Some record types are handled by one platform and ignored by the other, so anything meant for the public should be tested on both before it is produced in quantity.
What happens if I move the phone away mid write?
The tag loses power and the write stops. It can be left holding partial content that reads as corrupt rather than empty, which is why verifying a write matters more than it appears to.