There has been interest in the use of plant extract as a natural preservative agent for improving the oxidative stability of vegetable oils. However, plant extracts have low stability against heat and environmental stress. In this study, the antioxidant potential of nano‐ and microencapsulated Rosmarinus officinalis L. extract (RE) obtained using the ultrasonication method was measured. The total phenolic and flavonoid content of the extract was 174.4 ± 25.9 mg gallic acid/g extract and 78.30 ± 3.2 mg rutin/g extract, respectively. Antioxidant activity of 50, 100, 200, and 400 ppm of RE was measured by DPPH free radical scavenging methods, ferric reduction assay, and β‐carotene/linoleic acid assay, and then compared to the 100 ppm of TBHQ as a common synthetic antioxidant. The results showed that the antioxidant activity increased with increasing the concentration of the extract in all evaluating methods. The antioxidant activity of 200 ppm of the free and encapsulated extract in cress (Lepidium sativum) and basil (Ocimum basilicum) seed gums at different ratios (1:0, 1:1, and 0:1) was compared to sunflower oil without antioxidants, and oil‐containing TBHQ which was stored at 60°C for 24 days. The oxidation indexes of oil samples include peroxide value, thiobarbituric acid value, and p‐anisidine value measured at 4‐day intervals. A lower oil oxidation was observed in oil‐containing nanoencapsulated extract followed by microencapsulated extract, free extract, and TBHQ. Since producing nanoencapsulated RE requires a higher time and speed of homogenization and due to no statistically significant difference between the antioxidant properties of nanocapsules and microcapsules in oil, the use of microcapsules of RE in basil seed gum to increase the shelf life of sunflower oil is recommended.