Anti-Asian hate crimes escalated during the COVID-19 pandemic; however, limited research has explored the association between social media sentiment and hate crimes toward Asian communities. This study aims to investigate the relationship between Twitter (rebranded as X) sentiment data and the occurrence of anti-Asian hate crimes in New York City from 2019 to 2022, a period encompassing both before and during COVID-19 pandemic conditions. We used a hate crime dataset from the New York City Police Department. This dataset included detailed information on the occurrence of anti-Asian hate crimes at the police precinct level from 2019 to 2022. We used Twitter's application programming interface for Academic Research to collect a random 1% sample of publicly available Twitter data in New York State, including New York City, that included 1 or more of the selected Asian-related keywords and applied support vector machine to classify sentiment. We measured sentiment toward the Asian community using the rates of negative and positive sentiment expressed in tweets at the monthly level (N=48). We used negative binomial models to explore the associations between sentiment levels and the number of anti-Asian hate crimes in the same month. We further adjusted our models for confounders such as the unemployment rate and the emergence of the COVID-19 pandemic. As sensitivity analyses, we used distributed lag models to capture 1- to 2-month lag times. A point increase of 1% in negative sentiment rate toward the Asian community in the same month was associated with a 24% increase (incidence rate ratio [IRR] 1.24; 95% CI 1.07-1.44; P=.005) in the number of anti-Asian hate crimes. The association was slightly attenuated after adjusting for unemployment and COVID-19 emergence (ie, after March 2020; P=.008). The positive sentiment toward Asian tweets with a 0-month lag was associated with a 12% decrease (IRR 0.88; 95% CI 0.79-0.97; P=.002) in expected anti-Asian hate crimes in the same month, but the relationship was no longer significant after adjusting for the unemployment rate and the emergence of COVID-19 pandemic (P=.11). A higher negative sentiment level was associated with more hate crimes specifically targeting the Asian community in the same month. The findings highlight the importance of monitoring public sentiment to predict and potentially mitigate hate crimes against Asian individuals.