Adds a tax rate to an exclusive price, or removes a tax rate from an inclusive price, given a stated tax percentage.
Published for review. The Founder is checking every card himself; anything he strikes comes down the same hour.
Try it
Inputs
price (number, required) min 0 : The starting price
tax_rate_percent (number, required) min 0 : The tax (VAT or sales tax) rate as a percent
direction (string, required) one of: add, remove : "add" treats price as tax-exclusive and adds the tax; "remove" treats price as tax-inclusive and strips the tax out
Outputs
result: The resulting price after adding or removing tax
Steps
Convert the tax rate to a decimal: r = tax_rate_percent / 100.
If direction is "add": result = price * (1 + r) (price is treated as the tax-exclusive amount).
If direction is "remove": result = price / (1 + r) (price is treated as the tax-inclusive amount).
Round result to 2 decimal places.
Constants
None.
Sources
Value-Added Tax (VAT) (Investopedia, 2026-09-30T19:29:48Z) - General inclusive/exclusive tax arithmetic: tax-inclusive price = tax-exclusive price * (1 + tax rate); the inverse divides instead of multiplies.