IOTA Rebased - Keypairs from the CLI

unofficial site

- return to IOTA Rebased Useful Links

IOTA CLI Keypair Generation

It can be useful to have a large number of keypairs for a project. This code was used (Nov 2025) to generate a json with 100 keypairs using the IOTA CLI only at the Terminal.

STEP 1. Code below saved as 'generate_iota_keypairs.sh' using 'nano generate_iota_keypairs.sh'
STEP 2. Used 'chmod +x generate_iota_keypairs.sh' to add "executable" permission to the file
Step 3. Used './generate_iota_keypairs.sh' to execute the file

As usual, code reproduced here may have become corrupted on the page and so needs careful checking. The code may also be plain wrong, so do your own checks from official sources only.

 
        #!/bin/bash

# Generate 100 IOTA Rebased key pairs
# Output will be saved to keypairs.json

echo "[" > keypairs.json

for i in {1..100}
do
    echo "Generating keypair $i/100..."
    
    # Generate a new address and capture the output
    output=$(iota client new-address)
    
    # Extract the address
    address=$(echo "$output" | grep "│ address" | awk -F'│' '{print $3}' | xargs)
    
    # Extract the alias
    alias=$(echo "$output" | grep "│ alias" | awk -F'│' '{print $3}' | xargs)
    
    # Extract the recovery phrase
    phrase=$(echo "$output" | grep "│ recoveryPhrase" | awk -F'│' '{print $3}' | xargs)
    
    # Extract the publicBase64Key
    pubkey=$(echo "$output" | grep "│ publicBase64Key " | awk -F'│' '{print $3}' | xargs)
    
    # Add to JSON (add comma except for last entry)
    if [ $i -lt 100 ]; then
        echo "  {" >> keypairs.json
        echo "    \"id\": $i," >> keypairs.json
        echo "    \"alias\": \"$alias\"," >> keypairs.json
        echo "    \"address\": \"$address\"," >> keypairs.json
        echo "    \"publicBase64Key\": \"$pubkey\"," >> keypairs.json
        echo "    \"recoveryPhrase\": \"$phrase\"" >> keypairs.json
        echo "  }," >> keypairs.json
    else
        echo "  {" >> keypairs.json
        echo "    \"id\": $i," >> keypairs.json
        echo "    \"alias\": \"$alias\"," >> keypairs.json
        echo "    \"address\": \"$address\"," >> keypairs.json
        echo "    \"publicBase64Key\": \"$pubkey\"," >> keypairs.json
        echo "    \"recoveryPhrase\": \"$phrase\"" >> keypairs.json
        echo "  }" >> keypairs.json
    fi
done

echo "]" >> keypairs.json

echo "✅ Generated 100 keypairs and saved to keypairs.json"
    

Resulting JSON file

This should produce 'keypairs.json' with 100 keypairs, the form of the first of which is reproduced below


{
    "id": 1,
    "alias": "gifted-hedghog",
    "address": "0x***********c173be81a8d916aeca02e59298059786d9ba714b607d",
    "publicBase64Key": "SdHgTjcyrIHgfbiKJoT*************",
    "recoveryPhrase": "display poss **** ***** **** ***** ***** ***** ***** ***** ***** stoat"
  },
  {
    "id": 2,