Exhibit 23.1

Consent of Independent Registered Public Accounting Firm

We consent to the incorporation by reference in the Registration Statements (Form S-8 No. 333-59568 and 333-136958) and Post-Effective Amendment No. 1 (Form S-8 No. 333-59568 and 333-136958) pertaining to the O’Reilly Automotive, Inc. Profit Sharing and Savings Plan of our report dated June 25, 2025, with respect to the financial statements and schedule of the O’Reilly Automotive, Inc. Profit Sharing and Savings Plan included in this Annual Report (Form 11-K) for the year ended December 31, 2024.

/s/ Ernst & Young LLP

Kansas City, Missouri

June 25, 2025