Context. Determining the size distribution of asteroids is key to understanding the collisional history and evolution of the inner Solar System. Aims. We aim to improve our knowledge of the size distribution of small asteroids in the main belt by determining the parallaxes of newly detected asteroids in the Hubble Space Telescope (HST) archive and subsequently their absolute magnitudes and sizes. Methods. Asteroids appear as curved trails in HST images because of the parallax induced by the fast orbital motion of the spacecraft. Taking into account the trajectory of this latter, the parallax effect can be computed to obtain the distance to the asteroids by fitting simulated trajectories to the observed trails. Using distance, we can obtain the absolute magnitude of an object and an estimation of its size assuming an albedo value, along with some boundaries for its orbital parameters. Results. In this work, we analyse a set of 632 serendipitously imaged asteroids found in the ESA HST archive. Images were captured with the ACS/WFC and WFC3/UVIS instruments. A machine learning algorithm (trained with the results of a citizen science project) was used to detect objects in these images as part of a previous study. Our raw data consist of 1031 asteroid trails from unknown objects, not matching any entries in the Minor Planet Center (MPC) database using their coordinates and imaging time. We also found 670 trails from known objects (objects featuring matching entries in the MPC). After an accuracy assessment and filtering process, our analysed HST asteroid set consists of 454 unknown objects and 178 known objects. We obtain a sample dominated by potential main belt objects featuring absolute magnitudes (H) mostly between 15 and 22 mag. The absolute magnitude cumulative distribution log N(H > H0) ∝ α log(H0) confirms the previously reported slope change for 15 < H < 18, from α ≈ 0.56 to α ≈ 0.26, maintained in our case down to absolute magnitudes of around H ≈ 20, and therefore expanding the previous result by approximately two magnitudes. Conclusions. HST archival observations can be used as an asteroid survey because the telescope pointings are statistically randomly oriented in the sky and cover long periods of time. They allow us to expand the current best samples of astronomical objects at no extra cost in regard to telescope time.