🛠️ToolsShed

Tax Bracket Calculator

Estimate US federal income tax, effective rate, and marginal rate for any income.

Perguntas Frequentes

Implementação de Código

# US Federal 2024 Tax Brackets (Single filer)
TAX_BRACKETS = [
    (11600,  0.10),
    (47150,  0.12),
    (100525, 0.22),
    (191950, 0.24),
    (243725, 0.32),
    (609350, 0.35),
    (float('inf'), 0.37),
]

STANDARD_DEDUCTION = 14600  # 2024 single

def calculate_tax(gross_income: float) -> dict:
    taxable = max(0, gross_income - STANDARD_DEDUCTION)
    total_tax = 0
    breakdown = []
    prev_limit = 0

    for limit, rate in TAX_BRACKETS:
        if taxable <= prev_limit:
            break
        income_in_bracket = min(taxable, limit) - prev_limit
        tax_in_bracket = income_in_bracket * rate
        total_tax += tax_in_bracket
        breakdown.append({
            "rate": rate,
            "income": income_in_bracket,
            "tax": tax_in_bracket,
        })
        prev_limit = limit

    return {
        "gross": gross_income,
        "taxable": taxable,
        "total_tax": total_tax,
        "effective_rate": (total_tax / gross_income * 100) if gross_income > 0 else 0,
        "marginal_rate": breakdown[-1]["rate"] * 100 if breakdown else 0,
        "breakdown": breakdown,
    }

result = calculate_tax(80000)
print(f"Gross Income:   ${result['gross']:,.0f}")
print(f"Taxable Income: ${result['taxable']:,.0f}")
print(f"Total Tax:      ${result['total_tax']:,.2f}")
print(f"Effective Rate: {result['effective_rate']:.2f}%")
print(f"Marginal Rate:  {result['marginal_rate']:.0f}%")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.