Twenty U.S. states provide such compensation to some or all defendants who are not convicted after being charged with crimes in the criminal justice system, without a showing that their civil rights were violated (and as distinct from compensation for a wrongful conviction).
But only six states provide reimbursement for expenses at the trial court level without a showing of wrongful conduct by the prosecution for people who aren't public employees, and one of those restricts this remedy to misdemeanor cases, while the other restricts it to self-defense cases.
Also, not all states that provide compensation to acquitted defendants provide compensation to defendants whose cases are dismissed before trial. See pages 1276-1279 of the law review article cited below. Only Missouri clearly compensates criminal defendants who receive a pre-trial dismissal of the criminal charges against them, even if the criminal prosecution was not wrongful and the defendant was not a public employee.
The state of the law on this topic in the United States was summarized in a 2014 law review article by Ira P. Robbins, entitled "THE PRICE IS WRONG: REIMBURSEMENT OF EXPENSES FOR ACQUITTED CRIMINAL DEFENDANTS" in the Michigan State Law Review (starting at page 1251 of the 2014 volume of the journal).
Four states have adopted broadly applicable reimbursement laws:
Florida, Missouri, New Jersey, and North Carolina. . . .
Two states-Washington and Wyoming -reimburse acquitted defendants
based on the type or category of crime with which they were charged or
based on the type of defense they raised.
Wyoming is the only state in which defendants are reimbursed only for
misdemeanor acquittals, not for felony acquittals. In these
misdemeanor cases, the county is the entity that is responsible for
reimbursement."
Washington stands alone in providing reimbursement only for defendants
acquitted based on self-defense. Once the trier of fact has found
"that the defendant's claim of self-defense was sustained by a
preponderance of the evidence," the State must reimburse "all
reasonable costs, including loss of time, legal fees incurred, and
other expenses involved in [the] defense." . . .
At least seven states have laws allowing reimbursement specifically
for certain publicly employed defendants: Louisiana, Mississippi, New
Jersey, New York, Pennsylvania, Utah, and Virginia. These laws are
generally in lieu of, rather than in addition to, statutes providing
for the reimbursement of all acquitted defendants. Public-employee
reimbursement laws typically share three characteristics: (1) they
require that the employee be acquitted; (2) they require that the
alleged misconduct arise out of the scope of employment; and (3) they
apply to all public employees in any type of criminal proceeding.
Louisiana, Mississippi, New York, and Utah generally follow this
pattern, with a few exceptions. But for Mississippi, each of these
states includes the first requirement that the public employee be
acquitted or that the charges be dismissed before the employee may be
reimbursed. Utah's statute includes the additional qualification that
the employee must not be "found guilty of substantially the same
misconduct that formed the basis for the indictment or information.
The remaining states-New Jersey, Pennsylvania, and Virginia-while
generally conforming to the aforementioned characteristics, limit
reimbursement to specific categories of public employees. New Jersey,
for example, in addition to having a broadly applicable reimbursement
statute, also has laws specifically providing reimbursement for
public educators as well as for members of municipal police
departments. Notably, New Jersey's statute for municipal police
department members does not require that those members be acquitted in
order for the municipality to provide for their defense, unless the
"criminal proceeding [was] instituted by . . .the municipality."
Pennsylvania, through a court rule, provides reimbursement only for
judges. Virginia is an outlier in that it provides reimbursement only
to "any trustee, advisory committee member, officer, or employee of
the Retirement System" for alleged securities violations. . . .
In some states and under federal law, acquitted defendants may be
reimbursed for their legal costs only when the government prosecuted
the defendant in bad faith. The federal Hyde Amendment awards
acquitted defendants reasonable attorney's fees and "other litigation
expenses" when the defendant can prove that the prosecution's suit was
"vexatious, frivolous, or in bad faith. In addition to the federal
statute, at least six states-Arizona, California, Georgia, Idaho,
Michigan, and Tennessee-have similar statutory provisions. Under
Idaho's statute, "if the court certifies in the minutes that the
prosecution was malicious or without probable cause, it may order the
prosecutor to pay the costs of the action." Arizona's, California's,
and Georgia's statutory provisions mirror Idaho's language;
California's statute, however, is limited to misdemeanor or infraction
cases. Michigan's statute is substantively similar to the other four
laws, except that the government can be made liable only for "the
costs that accrued to the court, [such as] the witness and jury fees."
Moreover, similar to California's statute, it is limited to
misdemeanors and ordinance violations. Tennessee's statute is unique
in that it applies only to vexatious appellate proceedings. . . .
Two states-Maryland and Massachusetts--do not provide reimbursement
for any of an acquitted defendant's trial-level expenses; rather, they
limit reimbursement to the expenses incurred in certain appellate
proceedings, such as unsuccessful appeals by the State or
Commonwealth. In Maryland, the State can appeal from an appellate
court's judgment only in limited circumstances, and "[i]f the State
loses the appeal, the jurisdiction shall pay all the costs related to
the appeal, including reasonable attorney's fees incurred by the
defendant as a result of the appeal."81 Maryland provides an automatic
appeal in capital cases "of both the determination of guilt and the
sentence." Although the State provides no actual reimbursement to
defendants when such an appeal takes place, the State is responsible
for paying "the cost applicable to the sentencing proceeding" in the
automatic appeal. Massachusetts provides reimbursement through four
court rules. Under the first rule, the Commonwealth must pay the
defendant's "costs of appeal" and reasonable attorney's fees for
unsuccessful State interlocutory appeals from suppression rulings. The
purpose of this rule is "to 'provide[] a needed measure of protection
to the rights of defendants by seeking to equalize the resources of
the defendant with those of the Commonwealth.' As the Supreme Judicial
Court of Massachusetts has explained, "[a] defendant who is able to
retain private counsel may not have the funds for an interlocutory
appeal from a suppression motion on which he has prevailed. The lawyer
should not be placed in the untenable position of either volunteering
his services on the appeal or abandoning the defendant." Unlike the
mandatory nature of the previous rule, the other three rules permit,
but do not require, the appellate court to grant reimbursement of the
same costs and fees as under the first rule. The second rule applies
where the Commonwealth unsuccessfully appeals from a required finding
of not guilty or a reduction of a verdict, the third rule applies
generally where the Commonwealth unsuccessfully appeals from an order
granting a new trial, and the fourth rule applies specifically where
the Commonwealth unsuccessfully appeals from an order granting a new
trial in a capital case.
Thirty other states do not provide any reimbursement of costs under to acquitted criminal defendants or defendants against whom charges have been dismissed, apart from civil rights violations and wrongful convictions.
From the same source:
While a handful of states' laws limit reimbursement to specific and
narrowly defined expenses, other states' laws allow for reimbursement
of the defense's "costs," without defining what this may entail." The
types of costs most frequently addressed by reimbursement statutes and
case law include witness fees, legal document fees, attorney's fees,
detention costs, and "loss of time."
You can read the article for more details on precisely what compensation is available where. Essentially all of these remedies are limited to "compensatory" economic damages, and not to compensation for other forms of distress, harm to reputation, or other kinds of non-economic damages.