Based on the results from recent studies on biodiesel production, in addition to cost reduction, the electrolysis method has both quantitative and qualitative advantages over the reflux method. Thus, in this study, biodiesel was produced by the electrolysis of the oil of two sea microalgae strains, namely Chlorella vulgaris and Spirulina platensis, using methanol and prepared CaO/KOH-Fe3O4 and KF/KOH-Fe3O4 magnetic nanocatalysts. At the first step, magnetic nanocatalysts were prepared, Scanning electron microscope and X-ray diffraction patterns of the prepared nanocatalysts were studied, and the calculated average crystal size of CaO/KOH-Fe3O4 and KF/KOH-Fe3O4 was 55.91 nm and 42 nm, respectively. Brunauer-Emmett-Teller analysis was performed for the determination of the active surface area. Then, two types of mentioned nonfood microalgae were cultured, and the oil of them was extracted. The most suitable microalgae between these two types with regard to the culture condition was chosen for the last step. Then, electrolysis technique contains two graphite plate electrodes (3 cm × 3 cm) that are separated by a distance of 2 cm and potential difference of 54 V with the electrolysis cell which was filled with 100 mL of reaction mixture containing methanol, the aforementioned microalgae oil, Tetrahydrofuran (THF), water, and nanocatalysts was performed for biodiesel production. The effect of catalyst weight percentage (1, 1.5, 2 wt%), molar ratio of alcohol to oil (5:1, 6:1, 7:1), and the reaction time (30, 60, 120, 180 min) in the efficiency of biodiesel production was investigated, and the physical properties of the prepared biodiesel were quantified. Based on the results, Chlorella vulgaris microalgae because of the more obtainable oil shows the priority of microalgae over Spirulina platensis and KF/KOH-Fe3O4 is an optimal choice catalyst for biodiesel production. The optimal condition was using 1.5 wt% of catalyst, methanol/oil molar ratio of 1:6, temperature of 25 °C, stirring speed of 400 rpm, and the reaction time of 2 h. Furthermore, B20 was prepared using the obtained biodiesel, and the quality was in accordance with the world standard of fuel ASTM D975, with the process yield of 96.8%, and no saponification side reaction, and KF/KOH-Fe3O4 showed the higher mass yield in transesterification reaction.