Caffeine, a major ingredient of coffee and other drinks, causes minimal health problems. However, excessive caffeine intake may induce emotional and cardiac events. Studies on zebrafish larvae are considered useful for understanding drug poisoning because they can be used for multiple simulations. The locomotion (swim distance) of zebrafish larvae exposed to varying concentrations of caffeine was measured using a light–dark test and an automatic video-tracking system. Mortality and heart rates were assessed 4 and 24 h after caffeine exposure and 24 h after caffeine removal. The heart and survival rates were reduced by exposure to caffeine of > 300 mg/L after 24 h in a dose-dependent manner; this was attenuated by caffeine removal at 4 h. Caffeine reduced the heart rate and survival considerably at 1000 mg/L, supporting the notion of caffeine-induced cardiac arrest resulting from bradycardia. The locomotion of zebrafish larvae during six alternating cycles of light–dark exposure was slower during light periods and faster during dark periods; 100–300 mg/L caffeine increased and decreased locomotion during light and dark cycles, respectively, with high inter-cycle reproducibility. Given the anxiogenic effect of caffeine and light preference of zebrafish larvae, caffeine-induced changes in light–dark cycles could provide a new reliable marker for anxiety. Therefore, the “light–dark locomotion test” employed in this study is valuable for research on anxiogenic or anxiolytic substances. The test may allow simultaneous and automatic analysis of the locomotion of many fish under multiple conditions, thereby enabling evaluation of dose–response effects of caffeine.