In your Arduino IDE, go to File> Preferences
Enter https://dl.espressif.com/dl/package_esp32_index.json into the “Additional Board Manager URLs” field . Then, click the “OK” button:
Open the Boards Manager. Go to Tools > Board > Boards Manager…
Search for ESP32 and press install button for the “ESP32 by Espressif Systems“:
That’s it. It should be installed after a few seconds.
Note: if you already have the ESP8266 boards URL, you can separate the URLs with a comma as follows:
https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json
Links:
For ESP32 https://dl.espressif.com/dl/package_esp32_index.json For ESP8266 http://arduino.esp8266.com/stable/package_esp8266com_index.json