Tip Calculator: How to Calculate a Tip and Split the Bill
Calculating a tip seems simple — multiply the bill by a percentage. But once you add split bills, pre-tax vs post-tax tipping, and rounding to clean amounts per person, the arithmetic adds up fast. This guide explains the formulas, the conventions, and how to implement a tip calculator in four languages.
The Basic Tip Formula
Tip amount = Bill total × (Tip percentage / 100)
Total to pay = Bill total + Tip amount
Example: Bill is $85.00, tip is 18 %.
Tip = 85.00 × 0.18 = $15.30
Total = 85.00 + 15.30 = $100.30
That's the whole calculation. Everything else — splitting, rounding, pre/post-tax — is a variation on these two lines.
Splitting the Bill
When dividing evenly among N people:
Per person = Total to pay / N
With the example above, split 4 ways:
Per person = $100.30 / 4 = $25.075 → round to $25.08
Rounding each person's share independently can produce a total slightly different from the bill. The cleanest approach: calculate the total first, round it, then divide — or calculate per-person shares and adjust the last person's share to cover any remainder.
Common Tip Percentages
| Service quality | Typical tip (US) | Typical tip (UK) | Typical tip (EU) |
|---|---|---|---|
| Poor | 10 % | 0–5 % | 0 % |
| Acceptable | 15 % | 10 % | 5–10 % |
| Good | 18 % | 12.5 % | 10 % |
| Excellent | 20–25 % | 15 % | 10–15 % |
Tipping culture varies widely. In Japan, tipping is considered rude. In the US, 18–20 % is standard and often expected. In most of Western Europe, rounding up the bill or leaving 5–10 % is the norm.
Pre-tax vs Post-tax Tipping
In the US, the bill usually includes tax. You can tip on:
- Post-tax total — the amount shown on the bill. Easier, very slightly more generous.
- Pre-tax subtotal — the food/drink cost before tax. Technically more correct; slightly lower tip.
On a $85 pre-tax bill with 8 % tax ($6.80 = $91.80 total), the difference between tipping 18 % on $85 vs $91.80 is about $1.23 — negligible in practice.
Most people tip on the post-tax amount because that's the number they see first. Either is acceptable.
Code Examples
JavaScript
function calculateTip({ billTotal, tipPercent, numPeople = 1 }) {
const tipAmount = billTotal * (tipPercent / 100);
const grandTotal = billTotal + tipAmount;
const perPerson = grandTotal / numPeople;
return {
tipAmount: Math.round(tipAmount * 100) / 100,
grandTotal: Math.round(grandTotal * 100) / 100,
perPerson: Math.round(perPerson * 100) / 100,
};
}
const result = calculateTip({ billTotal: 85, tipPercent: 18, numPeople: 4 });
console.log(`Tip: $${result.tipAmount}`); // Tip: $15.30
console.log(`Total: $${result.grandTotal}`); // Total: $100.30
console.log(`Per person: $${result.perPerson}`); // Per person: $25.08
Note: Math.round(x * 100) / 100 is the standard JS trick for rounding to two decimal places. Avoid toFixed() for arithmetic — it returns a string, not a number.
Python
from decimal import Decimal, ROUND_HALF_UP
def calculate_tip(bill_total: float, tip_percent: float, num_people: int = 1) -> dict:
bill = Decimal(str(bill_total))
pct = Decimal(str(tip_percent)) / 100
two_dp = Decimal("0.01")
tip_amount = (bill * pct).quantize(two_dp, rounding=ROUND_HALF_UP)
grand_total = (bill + tip_amount).quantize(two_dp, rounding=ROUND_HALF_UP)
per_person = (grand_total / num_people).quantize(two_dp, rounding=ROUND_HALF_UP)
return {
"tip_amount": float(tip_amount),
"grand_total": float(grand_total),
"per_person": float(per_person),
}
result = calculate_tip(85.0, 18, 4)
print(f"Tip: ${result['tip_amount']:.2f}") # Tip: $15.30
print(f"Total: ${result['grand_total']:.2f}") # Total: $100.30
print(f"Per person: ${result['per_person']:.2f}") # Per person: $25.08
Using Decimal instead of float avoids floating-point representation errors (e.g. 0.1 + 0.2 = 0.30000000000000004 in plain Python).
Go
package main
import (
"fmt"
"math"
)
type TipResult struct {
TipAmount float64
GrandTotal float64
PerPerson float64
}
func round2(v float64) float64 {
return math.Round(v*100) / 100
}
func calculateTip(billTotal, tipPercent float64, numPeople int) TipResult {
tip := billTotal * (tipPercent / 100)
total := billTotal + tip
per := total / float64(numPeople)
return TipResult{
TipAmount: round2(tip),
GrandTotal: round2(total),
PerPerson: round2(per),
}
}
func main() {
r := calculateTip(85.0, 18, 4)
fmt.Printf("Tip: $%.2f\n", r.TipAmount) // $15.30
fmt.Printf("Total: $%.2f\n", r.GrandTotal) // $100.30
fmt.Printf("Per person: $%.2f\n", r.PerPerson) // $25.08
}
PHP
function calculateTip(float $billTotal, float $tipPercent, int $numPeople = 1): array {
$tipAmount = round($billTotal * ($tipPercent / 100), 2);
$grandTotal = round($billTotal + $tipAmount, 2);
$perPerson = round($grandTotal / $numPeople, 2);
return compact('tipAmount', 'grandTotal', 'perPerson');
}
$result = calculateTip(85.0, 18, 4);
echo "Tip: $" . number_format($result['tipAmount'], 2) . "\n"; // $15.30
echo "Total: $" . number_format($result['grandTotal'], 2) . "\n"; // $100.30
echo "Per person: $" . number_format($result['perPerson'], 2) . "\n"; // $25.08
PHP's round() with precision 2 handles standard tip rounding correctly out of the box.
Rounding Strategies for Split Bills
When splitting, rounding each share independently can cause a small discrepancy:
| Approach | Description | When to use |
|---|---|---|
| Round total, then divide | Fewest surprises, one canonical total | Most apps |
| Round each person's share | Intuitive, may miss/overshoot by $0.01 | Informal |
| Last person covers remainder | Guarantees exact bill coverage | Strict billing |
| Always round up per person | Ensures full coverage, slightly over | Cautious |
For a production app, round the grand total to the nearest cent, then divide. Show users the per-person share rounded to two decimal places. Add a note if the rounded shares don't sum exactly to the total.
Tip on Discounted Bills
If the bill was discounted (coupon, promo code), tip on the original pre-discount amount, not the reduced total. The service quality doesn't change because a discount was applied — the server's effort was the same.
Example: Original bill $100, 20 % discount → you pay $80. Tip 18 % on $100 = $18, not 18 % on $80 = $14.40. This is standard etiquette in most restaurants.
FAQ
What is a good tip percentage?
In the US, 18 % is considered the baseline for good service, 20 % is common for excellent service, and 15 % is acceptable for average service. Outside the US, check local customs — in many countries 10 % or simply rounding up is perfectly normal.
Should I tip on alcohol?
Yes, in the US. Alcohol is typically the highest-margin item on the bill, but the server still carries, opens, and pours it. Some diners tip differently on alcohol vs food; there is no strict rule.
How do I tip when using a coupon?
Tip on the pre-discount total. The coupon is between you and the restaurant — the server did the same work regardless.
Do I tip on takeout or delivery?
For delivery: yes, typically 10–20 % of the order total, or a flat $3–$5 minimum. For takeout (you pick up): optional; $1–2 or 10 % is common in the US when someone assembled your order.
What is the "double the tax" trick?
In US states with 8–9 % sales tax, doubling the tax gives you roughly 16–18 % tip — a quick mental shorthand without a calculator. It works well in New York (8.875 %) or California (varies 7.25–10.25 %).
How do tip pools work?
Some restaurants pool all tips and redistribute them among all staff (servers, bussers, hosts, kitchen). As a customer you tip normally; the distribution is the restaurant's policy. You can ask if you want your tip to go only to your server.
Calculate Your Tip Now
Skip the mental maths — use the Tip Calculator to instantly calculate the tip, the total, and the per-person share for any bill size and party.