Skip to content

Nostr Tags

Tags are key components of Nostr events that provide additional context, metadata, and relationships between events. They are especially important for the discoverability and interconnectedness of the Nostr protocol.

Available Tag Definitions

The following tags have detailed definitions in this documentation:

Tag NameDescriptionDefined in
aReferences an addressable or replaceable eventNIP-01
dProvides a unique identifier for addressable eventsNIP-01
eReferences another eventNIP-01
gProvides geographic location using a geohashNIP-52
hIdentifies a group in the relay-based groups systemNIP-29
iReferences external identities and content identifiersNIP-39, NIP-35, NIP-73
pReferences a user's public keyNIP-01
qReferences an event in a quote repostNIP-18
rReferences a URL or relay addressNIP-24, NIP-65
tHashtags for content categorizationNIP-24
-Indicates a "protected" event that can only be published by its authorNIP-70
clientIdentifies the client application that published an eventNIP-89
emojiDefines a custom emoji for use in event contentNIP-30
proxyLinks events to their original source from other protocolsNIP-48
zapSpecifies recipients for Lightning Network payments (zaps) on eventsNIP-57

Tag Format

In Nostr events, tags are represented as arrays of strings within the tags array of an event. The first element of a tag array is always the tag name, followed by one or more values.

Example:

json
{
  "kinds": 1,
  "tags": [
    ["client", "MyNostrClient"],
    ["d", "article-identifier"],
    ["e", "5c83da77af1dec6d7289834998ad7aafbd9e2191396d75ec3cc27f5a77226f36", "", "reply"],
    ["p", "32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245"],
    ["a", "30023:f7234bd4c1394dda46d09f35bd384dd30cc552ad5541990f98844fb06676e9ca:abcd"]
  ],
  // other fields...
}

Tag Categories

Tags in Nostr can serve several purposes:

  1. Referencing other events (e.g., e tag for event references)
  2. Referencing users (e.g., p tag for pubkey references)
  3. Referencing addressable content (e.g., a tag for replaceable or addressable events)
  4. Identifying content (e.g., d tag for uniquely identifying addressable events)
  5. Providing metadata (e.g., client tag for identifying the publishing application)
  6. Defining relationships (e.g., d tag for replaceable events)
  7. Structuring content (e.g., subject tag for setting a title)
  8. Group membership (e.g., h tag for associating events with a specific group)

Contributing

To add a new tag definition to this documentation, use the following command:

bash
deno task generate_tag <tag_name> <nip_number>