We developed an algorithm that is capable of retrieving MRI billing codes from MRI log data. This proof-of-concept work is applied to Tarmed, the Swiss fee-for-service tariff system for outpatient services, and is tested on two MRI scanners, a MAGNETOM Aera and a MAGNETOM Skyra (Siemens Healthcare, Erlangen, Germany), of a single radiology site. A machine learning approach for automated MRI billing code retrieval from MRI log data is implemented. The proposed algorithm reliably predicts medical billing codes for MRI exams (F1-score: 97.1%). Integrated in the clinical environment, this work has the potential to reduce the workload for technologists, prevent coding errors and enable scanner-specific expense and turnover analysis.