Baseball game

The Longest At-Bat

Can you beat Brandon Belt’s 21-pitch record? A pitch-by-pitch at-bat simulator built on 2025 MLB averages.

The game after a five-pitch strikeout: a scoreboard, a strike zone plot with numbered pitches, a pitch-by-pitch log, and a summary comparing the at-bat to the record.

What it is

The Longest At-Bat in short

On April 22, 2018, Brandon Belt saw 21 pitches in a single at-bat, the longest in Major League history. This game asks whether you can beat it.

Each pitch you choose to take, swing, swing for the fences or bunt. The game tracks it like a broadcast: the count, the bases, where every pitch crossed the plate, and how long the at-bat would have taken under the pitch clock.

At a glance

The Longest At-Bat

What
Free baseball simulation in the browser
The record
21 pitches, Brandon Belt, April 22, 2018
Odds from
2025 MLB averages
First version
2018

Features

What it does

  • Real odds

    Balls, strikes, fouls, whiffs and hits are based on 2025 MLB averages from Baseball Savant, FanGraphs and Baseball-Reference.

  • Pick your hitter

    Contact, power or patient, batting right, left or switch. Each changes how often you miss, foul off or read a pitch.

  • A different pitcher every time

    Each pitcher has their own pitch mix, velocity, control and stuff, and tires as their pitch count climbs.

  • A real game situation

    Every at-bat starts in a random, realistic inning, score and base state.

  • Broadcast-style tracking

    A strike-zone plot, a pitch-by-pitch log and a hit-location chart.

  • Context when it ends

    How your at-bat compares to the record, the 3.9-pitch average and the league strikeout rate.

Screenshots

The Longest At-Bat, screen by screen

Background

Why I built it

I started this game in 2018, the year Belt set the record, with help from Aquent Gymnasium’s JavaScript Foundations course. It has since grown into a broadcast-style, pitch-by-pitch tracker.

Under the hood

How it’s built

Plain HTML, CSS and JavaScript, with the strike zone and field drawn in SVG. The 2025 update rebuilt the odds from league averages (with a full source list saying which numbers are published and which are estimates), added batter and pitcher types, and moved hosting to Cloudflare Workers.

More projects

Other things I’ve built

  • The SEO Fetcher panel on its Issues tab, listing one error, two warnings and several notices, each with a short explanation.

    Chrome extension

    SEO Fetcher

    An on-page SEO inspector for Chrome: indexability, snippets, issues, and AI crawler access for the page you’re on.

    On the Chrome Web Store
  • A Pseudoku puzzle after two guesses: cells colored green for correct, yellow for close and red for wrong, with the clues for row 1 and column C shown above the grid.

    Daily puzzle

    Pseudoku

    A daily logic puzzle: fill a 4×4 grid so every row and column matches its clue, in five guesses or fewer.

    Live, new puzzle daily
  • Personal web app

    Reading Log

    My private reading tracker: a journal for every book, finish-date estimates, a stats dashboard, and a spoiler-aware reading companion.

    Live, sign-in only