How do I migrate my Bitcoin Core wallet to an HD wallet? I created a wallet before Bitcoin Core 0.13.0 was released so my wallet is not a HD wallet. How do I make my wallet a HD wallet?
Since Bitcoin Core 0.17, there is an automatic way to directly upgrade a wallet from non-HD to HD. Simply start Bitcoin Core with the  the -upgradewallet option and have no other wallets (i.e. remove all -wallet= and wallet= options from the command line and bitcoin.conf respectively) being loaded. -upgradewallet does not work when multiple wallets are loaded. This will automatically generate a new seed and keypool while also retaining all of your old private keys and transactions so nothing is lost.



Prior to Bitcoin Core 0.17, there was no mechanism for migrating non-HD wallets to HD wallets. If you don't want to upgrade to 0.17+, then migrating your coins to an HD wallet is possible, at the expense of invalidating your backups and a bit of work.

First you will need to backup your current wallet. Stop Bitcoin Core and back up your wallet.dat file. Now rename your wallet.dat file to something else, like wallet-orig.dat. 

Now start Bitcoin Core again. Bitcoin Core will create a new wallet.dat file. This one will be HD and that will be the file that you want to actually use later.

Once Bitcoin Core has started, encrypt your wallet and restart Bitcoin Core. Once you have restarted it, you should see no transactions and no (or one) addresses. Now get a couple of addresses and write them down somewhere. Stop Bitcoin Core again and backup your new wallet.dat file. Rename your new wallet.dat file to something else, like wallet-new.dat and rename your old wallet.dat file (wallet-orig.dat) back to wallet.dat.

Start Bitcoin Core again. You should see your old addresses and transactions. Go to the Send tab and send your Bitcoin to the addresses that you wrote down earlier.

Finally, stop Bitcoin Core, rename your new wallet.dat file (wallet-new.dat) back to wallet.dat. Back it up again and start Bitcoin Core again. You should now see transactions from your previous wallet sending Bitcoin to your new wallet. Once those transactions have confirmed, you have successfully migrated your Bitcoin from a non-HD Bitcoin Core wallet to a HD Bitcoin Core wallet.