In this post I am going to explain how to create customer programmatically in magento 2.

1. Using Dependency Injection

Add below code snippet in Block class.

2. Using Object Manager

Note: After creating customer you need to run indexer command to see a customer in the backend grid.

That’s it. Enjoy Magento 2!!