Jakarta is not a beach city -- the urban shoreline is industrial and the water is not for swimming. The escape is the Thousand Islands (Kepulauan Seribu), a chain of small coral islands strung out into the Java Sea north of the city.
Boats leave from Marina Ancol. Pulau Bidadari and Pulau Onrust are the closest, an hour out, and have colonial Dutch ruins as well as beaches. Pulau Pramuka has cheap homestays and is the easiest base for snorkelling. Pulau Macan and Pulau Kotok are further out, more pristine, and the diving and snorkelling improve sharply once you get past the first ring of islands. Pulau Pantara and Pulau Putri, two hours out by speedboat, are the top end -- resort accommodation and the clearest water of the chain.
Visibility and water quality drop noticeably during the rainy season (November to March). Weekends fill up with day-trippers from Jakarta; go midweek if you can.