Prompt
I'm building a shipping calculator and need tax by destination address
Latest observation
Nov 3, 2026
OpenAI APIWeb search: off
To calculate tax by destination address for a shipping calculator, you typically need to determine the tax jurisdiction from the full destination address, then apply the correct tax rules for that jurisdiction.
What you need from the destination address
At minimum:
- Country
- State / province / region
- City
- Postal / ZIP code
- Sometimes street address for more precise jurisdiction lookup
Basic approach
-
Validate and normalize the address
- Standardize abbreviations
- Ensure postal code format is valid
- Separate country/state/city/postal components
-
Map address to tax jurisdiction
- Use a tax engine or jurisdiction lookup database
- For some countries, tax can depend on:
- Country
- State/Province
- County
- City
- Special tax districts
-
Determine applicable tax rules
- Shipping taxability may differ from product taxability
- Some regions tax shipping, some do not
- Rates may vary by destination and item type
-
Calculate tax
tax = taxable_amount × applicable_tax_rate- If tax depends on multiple jurisdictions, combine them as required
Common implementation options
Option A: Use a tax API
Best if you need accurate, up-to-date rates. Examples:
- Avalara
- TaxJar
- Vertex
- Shopify Tax (if relevant)
Typical flow:
- Send destination address + line items + shipping charge
- API returns tax amount and jurisdiction breakdown
Option B: Maintain your own rate table
Good for simple cases or limited geographies. Example structure:
{
"US-CA-LosAngeles-90001": 0.095,
"US-NY-NewYork-10001": 0.08875
}
This is harder to maintain because tax rules change frequently.
Example calculation
If:
- Shipping cost = $20
- Destination tax rate = 8.25%
- Shipping is taxable
Then:
- Tax =
20 × 0.0825 = $1.65
Important considerations
- Shipping taxability: Shipping may be taxed separately from goods
- Tax-inclusive pricing: Some countries expect tax included in displayed price
- Nexus / registration: You may only need to collect tax where you’re registered
- Exemptions: Some destinations or item categories may be exempt
- Cross-border duties/import taxes: Separate from sales tax/VAT
Recommended next step
If you tell me:
- Which countries you ship to
- Whether you want sales tax, VAT, or both
- Your tech stack
I can help you design the exact tax lookup flow and provide sample code.