Baseball and Softball
Batting average, OBP, SLG and OPS.
Enter at-bats, hits, extra-base hits, walks, hit-by-pitch and sacrifice flies. You get batting average, on-base percentage, slugging percentage and OPS in the usual .333 format. Runs in your browser.
Batting line
Batting stats
Fill the form and press Calculate.
Worked example
A season of 500 at-bats with 150 hits (30 doubles, 5 triples, 20 home runs), 60 walks, 5 hit-by-pitch and 5 sacrifice flies. Singles = 150 − 30 − 5 − 20 = 95. Batting average = 150 / 500 = .300. OBP = (150 + 60 + 5) / (500 + 60 + 5 + 5) = 215 / 570 = .377. Total bases = 95 + 2×30 + 3×5 + 4×20 = 250, so SLG = 250 / 500 = .500. OPS = .377 + .500 = .877.
How it works
Batting average = H / AB. On-base percentage = (H + BB + HBP) / (AB + BB + HBP + SF). Slugging percentage = (1B + 2×2B + 3×3B + 4×HR) / AB, which is total bases divided by at-bats. OPS = OBP + SLG.
Walks, hit-by-pitch and sacrifice flies do not count as at-bats, so batting average ignores them while OBP includes them. Sacrifice bunts are not counted in either formula. Softball scorekeeping uses the same formulas.
Sources and basis (checked 2026-10-05): MLB.com Glossary, Batting Average; MLB.com Glossary, Slugging Percentage; MLB.com Glossary, OPS; Baseball-Reference, On-base percentage (OBP formula with HBP and SF).
FAQ
How do you calculate batting average?
Divide hits by at-bats. 150 hits in 500 at-bats is .300.
What is the on-base percentage formula?
OBP = (hits + walks + hit by pitch) / (at-bats + walks + hit by pitch + sacrifice flies).
How is slugging percentage calculated?
Total bases divided by at-bats, where a single is 1 base, a double 2, a triple 3 and a home run 4.
What is a good OPS?
OPS adds OBP and slugging, so higher is better. What counts as good depends on the league and level, so compare against league averages for the same season.
Do walks count as at-bats?
No. Walks, hit-by-pitch and sacrifice flies are plate appearances but not at-bats.
Disclaimer
Formulas follow standard baseball scoring. Official league stats may differ in how a play is scored.