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

Related Read:  10+ Auto Parts Magento 2 Themes For Successful Ecommerce Business

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

Related Read:  How to Enable Gift Options in Magento 2

That’s it. Enjoy Magento 2!!