Appearance
Tag: emoji
Overview
The "emoji" tag is used to define custom emoji that can be rendered in Nostr content. It provides a way to associate a shortcode (like :smiley:
) with a URL pointing to an image, allowing clients to replace the shortcode with the custom emoji image when displaying the content.
Specification
Property | Value |
---|---|
Tag Name | emoji |
Defined in | NIP-30 |
Required for | Kind 0 (Profile Metadata), Kind 1 (Text Note), Kind 7 (Reaction), Kind 30315 (User Status) |
Format
["emoji", "<shortcode>", "<image-url>"]
Usage Description
The "emoji" tag defines a custom emoji that can be used in the event content. It consists of:
- shortcode: A name given to the emoji, which MUST be comprised only of alphanumeric characters and underscores.
- image-url: A URL to the corresponding image file of the emoji.
When creating content, users can insert custom emoji using the syntax :shortcode:
. Clients should parse these shortcodes and replace them with the corresponding emoji images defined in the event's "emoji" tags.
Examples
Basic Example
json
["emoji", "soapbox", "https://gleasonator.com/emoji/Gleasonator/soapbox.png"]
Multiple Emoji Tags Example
json
{
"kind": 1,
"content": "Hello :gleasonator: 😂 :ablobcatrainbow: :disputed: yolo",
"tags": [
["emoji", "ablobcatrainbow", "https://gleasonator.com/emoji/blobcat/ablobcatrainbow.png"],
["emoji", "disputed", "https://gleasonator.com/emoji/Fun/disputed.png"],
["emoji", "gleasonator", "https://gleasonator.com/emoji/Gleasonator/gleasonator.png"]
],
"pubkey": "79c2cae114ea28a981e7559b4fe7854a473521a8d22a66bbab9fa248eb820ff6",
"created_at": 1682630000
}
Client Behavior
Clients should:
- Parse content for patterns like
:shortcode:
and replace them with the corresponding emoji image. - For kind 0 events, "emojify" the
name
andabout
fields in the parsed JSON content. - For kind 1, kind 7, and kind 30315 events, "emojify" the
content
field. - Potentially allow users to select and insert custom emoji when composing posts by:
- Showing a picker UI for emoji
- Automatically adding the necessary "emoji" tags when a custom emoji is inserted
Relay Behavior
Relays have no specific requirements for handling "emoji" tags beyond normal event processing. Relays do not need to validate or process the emoji tags in any special way.
References
Related Tags
- None directly related.
Notes
- When implementing custom emoji support, clients should be mindful of:
- Image sizing to maintain UI consistency
- Potential abuse vectors (e.g., extremely large images)
- Accessibility considerations (alt text could potentially use the shortcode)
- The shortcode format (
:shortcode:
) is similar to that used by other platforms like Discord, Slack, and Mastodon. - Custom emoji should not be confused with Unicode emoji (like 😂), which are supported natively without tags.