Batting average calculator
This batting average calculator divides hits by at-bats and also works out on-base percentage, slugging and OPS. For pitchers it calculates ERA and WHIP. A hitter with 120 hits in 400 at-bats bats .300.
How it is calculated
Batting average = hits ÷ at-bats. That is how Rule 9.21(b) of the Official Baseball Rules defines it: divide the total number of safe hits (not the total bases on hits) by the total times at bat. 120 hits in 400 at-bats is .300.
Formulas from Rule 9.21 and the MLB glossary
- OBP = (hits + walks + hit by pitch) ÷ (at-bats + walks + hit by pitch + sacrifice flies) – Rule 9.21(f).
- SLG = total bases ÷ at-bats – Rule 9.21(c). Total bases count a single as 1, a double as 2, a triple as 3 and a home run as 4.
- OPS = OBP + SLG – the MLB glossary: OPS adds on-base percentage and slugging percentage.
- ERA = earned runs × 9 ÷ innings pitched, including fractions of an inning – Rule 9.21(e).
- WHIP = (walks + hits) ÷ innings pitched – MLB glossary.
Examples
| At-bats | Hits | AVG |
|---|---|---|
| 4 | 1 | .250 |
| 400 | 120 | .300 |
| 550 | 187 | .340 |
With 25 doubles, 2 triples, 15 home runs, 50 walks, 5 hit-by-pitches and 5 sacrifice flies, the same .300 hitter has 194 total bases, an OBP of .380 (175 ÷ 460), an SLG of .485 and an OPS of .865. For pitchers, the rule’s own example: 9 1/3 innings and 3 earned runs give an ERA of 2.89. With 8 hits and 2 walks in those innings, the WHIP is 1.07.
For 7-inning games the calculator can also multiply by 7 instead of 9 – a calculated variant, because Rule 9.21(e) itself uses 9. 3 earned runs in 7 innings are then 3.00, while the 9-inning formula gives 3.86.
Related: the average calculator and the online scoreboard.
Frequently asked questions
How do you calculate batting average?
Divide hits by at-bats: 120 ÷ 400 = .300. Walks, hit-by-pitches and sacrifice flies are not at-bats.
How is ERA calculated?
Earned runs × 9 ÷ innings pitched. Rule 9.21(e) gives the example 3 earned runs in 9 1/3 innings = 2.89.
What does 6.2 innings mean?
Six innings and two outs, that is 6 2/3 innings. Enter 6 full innings and 2 extra outs.
How is OPS calculated?
OPS is on-base percentage plus slugging percentage, for example .380 + .485 = .865.
How do I calculate ERA for 7 innings?
Multiply earned runs by 7 instead of 9 and divide by innings pitched: 3 earned runs in 7 innings give 3.00.
What is WHIP?
Walks plus hits divided by innings pitched; 10 walks and hits in 9 1/3 innings are 1.07.
Sources and legal basis
- MLB, Official Baseball Rules 2026, Rule 9.02(a)(1) times at bat; Rule 9.21 Determining Percentage Records: (b) batting average, (c) slugging percentage, (e) earned-run average incl. Comment (9 1/3 innings, 3 earned runs = 2.89), (f) on-base percentage (read 10.10.2026)
- MLB Glossary, On-base Plus Slugging (OPS): adds on-base percentage and slugging percentage (read 10.10.2026)
- MLB Glossary, Walks And Hits Per Inning Pitched (WHIP): the sum of a pitcher’s walks and hits, divided by his total innings pitched (read 10.10.2026)
As of: · Editorial policy
Related tools
- Average CalculatorAverage calculator: mean, median, mode and weighted average of your numbers with working and frequency table – plus the value needed for a target average.
- Winning Percentage CalculatorWinning percentage calculator: enter wins, losses and ties to get the win % and the .650 decimal, choose how ties count and see the wins needed for a goal.
- Percentage CalculatorFree percentage calculator: find X% of a number, what percent one number is of another, percentage change, increase and discount – with formula and steps.
- Bowling Score CalculatorFree bowling score calculator: tap each roll and it scores strikes, spares and the 10th frame by the official USBC rules, with running total and maximum.
- Golf handicap calculatorGolf handicap calculator using the World Handicap System: Handicap Index from your rounds (score, course rating, slope) and the course handicap for any course.
- Online scoreboard for two teamsFree online scoreboard for two teams: huge full-screen numbers, tap for +1/−1, sets, game clock, side switch and team colours. No app, no sign-up.
- BMI calculator (WHO categories)BMI calculator in lb and ft/in or kg and cm: your body mass index with WHO category on a colour scale, healthy weight range for your height and BMI Prime.
- Audiobook speed calculatorAudiobook speed calculator: enter the length and playback speed to see how long the book takes at 1.25×, 1.5× or 2×, the time you save and days to finish.
- A1C calculator: convert A1C and average glucoseA1C calculator: convert A1C % to estimated average glucose (eAG) in mg/dL and mmol/L, to IFCC mmol/mol, or work back from your average blood sugar.