Skip to content

Repository files navigation

netto

Documentation Status PyPI version CI codecov License Ruff

netto is a German income tax (Einkommensteuer) and social security (Sozialabgaben) calculator written in Python. It calculates net income from gross salary considering various tax brackets, social security contributions, solidarity tax (Solidaritätszuschlag), and optional church tax.

Features

  • Calculate net income from gross salary with calc_netto()
  • Calculate required gross salary for desired net income with calc_inverse_netto()
  • Support for tax years 2018-2026
  • Married couples support (Ehegattensplitting, including dual-income households)
  • Children support: Kindergeld and Kinderfreibetrag with automatic Günstigerprüfung, plus the nursing care insurance effect
  • Optional church tax (8-9%, configurable)
  • Public health and pension insurance calculations
  • West-German pension deduction (East German support planned)
  • Type-safe configuration with Pydantic validation
  • Comprehensive documentation on ReadTheDocs

Installation

Install from PyPI using pip:

pip install netto

Requires Python 3.10 or higher.

Quick Start

Basic Usage

from netto import calc_netto

# Calculate net income from 50,000€ gross salary (uses defaults)
net_income = calc_netto(50000)
print(f"Net income: {net_income}€")
# Output: Net income: 31674.4€

Custom Configuration

from netto import calc_netto, calc_inverse_netto, TaxConfig

# Configure for 2026, married couple, two children, no church tax
config = TaxConfig(
    year=2026,
    is_married=True,
    num_children=2,  # includes Kindergeld and the Günstigerprüfung
    church_tax=0.0,  # Set to 0.09 for 9% church tax
    extra_health_insurance=0.017,  # Your Krankenkasse's Zusatzbeitrag
    # (omit to use the official year average)
)

# Calculate net income
net = calc_netto(50000, config=config)
print(f"Net income: {net}€")

# Calculate required gross salary for desired net income
gross = calc_inverse_netto(35000, config=config)
print(f"Required gross: {gross}€")

Dual-Income Married Couples

For jointly assessed couples where both partners work, pass the spouse's salary as partner_salary. Income tax is assessed jointly (Ehegattensplitting) while social security contributions are calculated per person:

from netto import calc_netto, calc_inverse_netto, TaxConfig

config = TaxConfig(year=2025, is_married=True, church_tax=0.0)

# Combined household net income for 80,000€ + 50,000€ gross salaries
household_net = calc_netto(80000, config=config, partner_salary=50000)
print(f"Household net income: {household_net}€")

# Required primary salary for a desired household net income,
# with the partner salary fixed
gross = calc_inverse_netto(90000, config=config, partner_salary=50000)
print(f"Required gross: {gross}€")

With Deductibles and Verbose Output

from netto import calc_netto, TaxConfig

config = TaxConfig(year=2024)

# Calculate with 2000€ deductibles and verbose output
net = calc_netto(
    salary=60000,
    deductibles=2000,  # e.g., professional expenses
    verbose=True,      # Print detailed breakdown
    config=config
)

Advanced: Using Helper Functions

For more granular control, you can use the intermediate calculation functions:

from netto import calc_taxable_income, calc_deductible_social_security, get_marginal_tax_rate

salary = 50000

# Calculate deductible social security contributions
deductible_social_security = calc_deductible_social_security(salary)

# Calculate taxable income
taxable_income = calc_taxable_income(
    salary=salary,
    deductible_social_security=deductible_social_security
)

# Get marginal tax rate for this income level
marginal_rate = get_marginal_tax_rate(taxable_income)
print(f"Marginal tax rate: {marginal_rate:.1%}")

Configuration

The TaxConfig dataclass provides type-safe configuration:

Parameter Type Default Description
year int 2025 Tax year (2018-2026 supported)
is_married bool False Married status (Ehegattensplitting)
has_children bool False Has (or ever had) children — removes the nursing insurance childless surcharge. Implied by num_children > 0
num_children int 0 Children entitled to Kindergeld. When set, calc_netto includes Kindergeld and applies the Günstigerprüfung (Kindergeld vs. Kinderfreibetrag)
church_tax float 0.09 Church tax rate (0.0-0.09, set to 0.0 for none)
extra_health_insurance float | None None Total health insurance Zusatzbeitrag. None uses the official year-specific average (e.g. 2.9% in 2026); set explicitly to match your Krankenkasse

Supported Tax Years

Year Status Notes
2018-2025 Fully supported Enacted tax law
2026 Fully supported Preliminary official data
2027-2032 Forecast Estimates for planning; see data/README.md for assumptions

Documentation

Full documentation is available at netto.readthedocs.io.

Data Sources

All tax calculations are based on official German government sources:

Development

Setup

# Clone the repository
git clone https://github.com/0-k/netto.git
cd netto

# Install in development mode with dev dependencies
pip install -e .
pip install -r requirements-dev.txt

# Set up pre-commit hooks (recommended)
pre-commit install

Pre-commit hooks automatically run ruff linting and formatting before each commit, preventing CI failures.

Running Tests

# First-time setup: install package in editable mode
pip install -e .

# Run all tests with coverage
python -m pytest --cov=netto test/

# Run specific test file
python -m pytest test/test_main.py -v

Note: Use python -m pytest (not just pytest) to ensure tests run in the correct Python environment where netto is installed.

Code Quality

# Format code
ruff format .

# Lint code
ruff check .

# Fix linting issues automatically
ruff check --fix .

Building Documentation

cd docs/
make html
# Open docs/_build/html/index.html in your browser

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

Created and maintained by Martin Klein (hi@martinklein.co).

Repository: https://github.com/0-k/netto Documentation: https://netto.readthedocs.io/ PyPI: https://pypi.org/project/netto/


© 2025 Martin Klein

About

German income tax (Einkommensteuer) and social security (Sozialabgaben) calculator

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Generated from 0-k/python-template