Description
Sometimes you need one Nostr identity.
Sometimes you need 25.
Sometimes you need 2,000 and installing half of GitHub just to generate some keys feels insulting.
npmkr.py is a single-file, dependency-free Python utility for generating valid Nostr keypairs in bulk.
python3 npmkr.py
That makes one.
python3 npmkr.py 25
That makes 25.
python3 npmkr.py 2000 rats.txt
That makes 2,000 and writes them to rats.txt.
No pip install.
No Nostr SDK.
No external crypto package.
No relay connection.
No internet connection required.
What It Generates
Every generated identity contains four values:
npub: npub1...
nsec: nsec1...
public_key: 0123456789abcdef...
private_key: 0123456789abcdef...
Each identity is written as one simple four-line block with a blank line between records.
The default output file is:
nostr_keys.txt
The script uses cryptographically secure randomness, performs the required secp256k1 public-key derivation internally, and generates the Bech32 npub and nsec representations itself.
Use It From Another Python Program
npmkr.py can also be dropped beside another Python script and imported directly.
from npmkr import generate_keys
keys = generate_keys(25)
print(keys[0]["npub"])
print(keys[0]["nsec"])
print(keys[0]["public_key"])
print(keys[0]["private_key"])
generate_keys() defaults to one identity and returns a normal Python list of dictionaries.
Importing the module does not generate keys, write files, or print anything.
You can also write keys using the built-in output function:
from npmkr import generate_keys, write_keys
keys = generate_keys(25)
write_keys(keys, "keys.txt")
Or generate and save them in one shot:
from npmkr import generate_and_write
keys = generate_and_write(25, "keys.txt")
Included
npmkr.pyREADME.txt
That’s it.
No package hierarchy.
No requirements.txt.
No virtual environment stuffed with somebody else’s problems.
Private Key Warning
The generated output contains real private keys.
Public:
npub
public_key
Keep secret:
nsec
private_key
On POSIX systems the output file is created with restrictive permissions where supported, and the script refuses to silently overwrite an existing key file.
What It Does Not Do
This tool generates Nostr identities and keypairs.
It does not publish profiles, create usernames, upload avatars, contact relays, follow accounts, post notes, or phone home.
If another script needs one valid Nostr identity or a pile of them, this is the boring little tool that does that job.
npmkr.py
one file.
make keys.
go away.





