Narrative:

During climb to FL380 started getting fumes of unknown origin in cockpit; smelled like something electrical burning or overheating. Asked the captain if he smelled something; which he did. While investigating instruments and lights for 2-3 minutes; [the] smell started to dissipate. We started discussing possible causes and plan of action. Closest airports were ZZZ1; ZZZ2; and ZZZ. Got weather for ZZZ2 and ZZZ. After level off at FL380; the smell started to come back. Once the smell came back; [we] swapped roles and [requested priority handling]; requesting a divert to ZZZ due to familiarity and less traffic congestion. While I talked to ATC and started flying forward ZZZ; pm (pilot monitoring) started setting us up for ZZZ. After setting up approach notified [operations control]. Landed in ZZZ uneventfully; taxied off runway and got inspected by fire crews which didn't see anything on thermal scan. Taxied to ramp to have maintenance check the aircraft.

Google
 

Original NASA ASRS Text

Title: Large Transport aircraft flight crew reported intermittent burning electrical fumes during cruise. After troubleshooting the problem; the flight crew decided to divert.

Narrative: During climb to FL380 started getting fumes of unknown origin in cockpit; smelled like something electrical burning or overheating. Asked the Captain if he smelled something; which he did. While investigating instruments and lights for 2-3 minutes; [the] smell started to dissipate. We started discussing possible causes and plan of action. Closest airports were ZZZ1; ZZZ2; and ZZZ. Got weather for ZZZ2 and ZZZ. After level off at FL380; the smell started to come back. Once the smell came back; [we] swapped roles and [requested priority handling]; requesting a divert to ZZZ due to familiarity and less traffic congestion. While I talked to ATC and started flying forward ZZZ; PM (Pilot Monitoring) started setting us up for ZZZ. After setting up approach notified [Operations Control]. Landed in ZZZ uneventfully; taxied off runway and got inspected by fire crews which didn't see anything on thermal scan. Taxied to ramp to have Maintenance check the aircraft.

Data retrieved from NASA's ASRS site and automatically converted to unabbreviated mixed upper/lowercase text. This report is for informational purposes with no guarantee of accuracy. See NASA's ASRS site for official report.