According to the American Bar Association, the purpose of bail is to make sure the defendant appears for trial and all pre-trial hearings. Bail is the amount of money defendants must pay to be released from custody before their trial. The bail is returned to the defendant after the trial.
A judge or magistrate decides the amount of bail depending on the defendant's risk of fleeing, the crime the defendant is accused of, the dangerousness of the defendant and the threat the defendant poses to the community. Bail is sometimes dependent on the behavior of the defendant while out of custody.