En Trillion dollar
www.bbc.com
That brings the total cost - based on official data - to $822bn between 2001 and 2019, but it doesn't include any spending in Pakistan, which the US uses as a base for Afghan-related operations.
According to a Brown University study in 2019, which has looked at war spending in both Afghanistan and Pakistan, the US had spent around $978bn (their estimate also includes money allocated for the 2020 fiscal year).

Afghanistan: What has the conflict cost the US and its allies?
How much has been spent on foreign military intervention in Afghanistan over the past two decades?

That brings the total cost - based on official data - to $822bn between 2001 and 2019, but it doesn't include any spending in Pakistan, which the US uses as a base for Afghan-related operations.
According to a Brown University study in 2019, which has looked at war spending in both Afghanistan and Pakistan, the US had spent around $978bn (their estimate also includes money allocated for the 2020 fiscal year).