Wanted: Generate a 12 word seed phrase for testing

I want an easy mechanism to generate a 12 word seed phrase for testing.

Ideally that I can run via npx

I currently use MyCrypto but would like to do this from the command line.

Suggestions appreciated.

UPDATE: @itinance created mnemonics, no need to install anything, just run npx mnemonics to get a mnemonic for testing.

$ npx mnemonics
npx: installed 15 in 6.4s
sustain law swift world vintage cute own ... ... ... 

Hi @abcoathup

i use some libraries for this.

For Node/JavaScript:

import bip39 from 'bip39';

const mnemonic = bip39.generateMnemonic();

With this you can easily create a CLI command creating new mnemonics :slight_smile:

More info can be found here:

1 Like

And for PHP using bitwasp/bitcoin:

 * @return string
 * @throws \BitWasp\Bitcoin\Exceptions\RandomBytesFailure
public function generateMnemonic()
    $random = new Random();
    $entropy = $random->bytes(Bip39Mnemonic::MAX_ENTROPY_BYTE_LEN);

    $bip39 = MnemonicFactory::bip39();

    $mnemonic = $bip39->entropyToMnemonic($entropy);

    return $mnemonic;
1 Like

I’ve just created a CLI tool for this.

npm install -g mnemonics

It will create a seed and print out 12 words phrase onto the console.

If you use a mac, you can easily put it into the clipboard for convinience

mnemonics | pbcopy

I made an alias for myself:

alias m=mnemonics

everytime I type “m” in terminal, i get new mnemonics :slight_smile:


Awesome @itinance

Ideally I want to run without having to install anything.

$ npx cowsay awesome
npx: installed 10 in 8.514s
< awesome >
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

When I do the same for mnemonics I get an error:

$ npx mnemonics
npx: installed 15 in 3.739s
EISDIR: illegal operation on a directory, read

Hm… i’m not familiar with npx and don’t know how it will deal with paths and files. However, pull requests are welcome :slight_smile:
You could create an Issue on the github repository.

1 Like

npx is awesome, it is an npm package runner, and is part of npm.

As well as running locally installed packages, it is great when using a package such as mnemonics that aren’t run very frequently, as you can run it without installing anything.

I have created an issue https://github.com/itinance/mnemonics/issues/1 :smile:

1 Like

Hi @itinance I created a pull request which appears to resolve the issue running the uninstalled package via npx.


THANK YOU for this @abcoathup! I have merged it now and released an update


@itinance Thank you so much for creating this.

Being able to run a package via npx without installing to create a mnemonic for test purposes is awesome!

$ npx mnemonics
npx: installed 15 in 6.4s
sustain law swift world vintage cute own ... ... ...
1 Like

You’re welcome! Glad to read this. But the idea was your idea :slight_smile: I’ve been working for 2 years now with the library behind within bigger projects that it was very easy to built a simple cli tool out of that now :slight_smile:

1 Like

Hi @itinance

I added a minor pull request to update the README to show the no installation usage.

1 Like