A method and an electronic device for detecting a vehicle queue length are disclosed. The method includes: when determining that a traffic light turns green, obtaining vehicle information of each vehicle on a lane section to be detected in a first preset time period before a time point when the traffic light turns green; determining at least one vehicle that has a static position and a static time point on the lane section to be detected; determining a first queuing vehicle and a last queuing vehicle on the lane section to be detected based on the at least one vehicle that has the static position and the static time point on the lane section to be detected; and determining a vehicle queue length on the lane section to be detected based on a position of the first queuing vehicle and a position of the last queuing vehicle.