Step 1 of 5
The code is the content
Put the snippet in the content exactly as written. Clients keep whitespace and indentation and offer one-click copy.
NIP-C0
DraftEvents
Share code as kind 1337 events: the content is the code, and tags give the language, file name, license, dependencies and source repository.
Edit the form or the JSON: both stay in sync, the badge says whether the result is valid, and tapping any field explains it.
Not signed yet · Demo keys only. These personas' secret keys are public on purpose.
Select any field in the form or the JSON to see what it does.
Step 1 of 5
Put the snippet in the content exactly as written. Clients keep whitespace and indentation and offer one-click copy.
No course chapter covers this NIP yet. The editor above is the quickest way in.
A snippet is a regular NIP-01 event.
repo can point at a NIP-34 repository announcement (kind 30617).
Specification text is quoted in English from the nostr-protocol/nips repository. Our explanations and the interface are translated. Source on GitHub at commit 0046368
This NIP defines a new event kind for sharing and storing code snippets. Unlike regular text notes (kind:1), code snippets have specialized metadata like language, extension, and other code-specific attributes that enhance discoverability, syntax highlighting, and improved user experience.
This NIP defines kind:1337 as a code snippet event.
The .content field contains the actual code snippet text.
l - Programming language name (lowercase). Examples: "javascript", "python", "rust"name - Name of the code snippet, commonly a filename. Examples: "hello-world.js", "quick-sort.py"extension - File extension (without the dot). Examples: "js", "py", "rs"description - Brief description of what the code doesruntime - Runtime or environment specification (e.g., "node v18.15.0", "python 3.11")license - License under which the code (along with any related data contained within the event, when available, such as the description) is shared. This MUST be a standard SPDX short identifier (e.g., "MIT", "GPL-3.0-or-later", "Apache-2.0") when available. An additional parameter containing a reference to the actual text of the license MAY be provided. This tag can be repeated, to indicate multi-licensing, allowing recipients to use the code under any license of choosing among the referenced onesdep - Dependency required for the code to run (can be repeated)repo - Reference to a repository where this code originates. This MUST be either a standard URL or, alternatively, the address of a NIP-34 Git repository announcement event in the form "30617:<32-bytes hex a pubkey>:<d tag value>". If a repository announcement is referenced, a recommended relay URL where to find the event should be provided as an additional parameter{
"id": "<32-bytes lowercase hex-encoded SHA-256 of the the serialized event data>",
"pubkey": "<32-bytes lowercase hex-encoded public key of the event creator>",
"created_at": <Unix timestamp in seconds>,
"kind": 1337,
"content": "function helloWorld() {\n console.log('Hello, Nostr!');\n}\n\nhelloWorld();",
"tags": [
["l", "javascript"],
["extension", "js"],
["name", "hello-world.js"],
["description", "A basic JavaScript function that prints 'Hello, Nostr!' to the console"],
["runtime", "node v18.15.0"],
["license", "MIT"],
["repo", "https://github.com/nostr-protocol/nostr"]
],
"sig": "<64-bytes signature of the id>"
}
Clients that support this NIP SHOULD:
Clients MAY provide additional functionality such as: