PHPackages                             rechtlogisch/steuernummer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. rechtlogisch/steuernummer

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

rechtlogisch/steuernummer
=========================

Normalize, denormalize and validate German tax numbers (Steuernummer)

v1.2.0(11mo ago)24.5k—6.9%1MITPHPPHP ^8.2CI passing

Since Jul 9Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/rechtlogisch/steuernummer)[ Packagist](https://packagist.org/packages/rechtlogisch/steuernummer)[ Docs](https://github.com/rechtlogisch/steuernummer)[ RSS](/packages/rechtlogisch-steuernummer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (0)

[![Recht logisch Steuernummer banner image](rechtlogisch-steuernummer-banner.png)](rechtlogisch-steuernummer-banner.png)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6e82f61601b04a1574a802e76dd7f32c4a9273cdd16cc89a5fa1a38300260017/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72656368746c6f67697363682f7374657565726e756d6d65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rechtlogisch/steuernummer)[![Tests](https://github.com/rechtlogisch/steuernummer/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/rechtlogisch/steuernummer/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/c72f37c93c9734d201d8f12f7561aced6dde432e2a5d1845ccbe98619fc7b4c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72656368746c6f67697363682f7374657565726e756d6d65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rechtlogisch/steuernummer)

steuernummer
============

[](#steuernummer)

> Normalize, denormalize and validate German tax numbers (Steuernummer)

Formats bidirectionally German tax numbers originating from tax office letters (German: Bescheidformat) or the ELSTER-Format (German: bundeseinheitliches ELSTER-Steuernummerformat) and validates it.

Based on the [official ELSTER documentation](https://download.elster.de/download/schnittstellen/Pruefung_der_Steuer_und_Steueridentifikatsnummer.pdf) (chapters: 3 - 7; as of 2025-02-24). Inspired by [kontist/normalize-steuernummer](https://github.com/kontist/normalize-steuernummer) and [kontist/denormalize-steuernummer](https://github.com/kontist/denormalize-steuernummer).

Note

This package validates solely the syntax and check digit of the provided input. It does not confirm, that the provided Steuernummer was assigned to any entity. Please contact the responsible tax office in case of any doubts concerning the correctness of your Steuernummer.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require rechtlogisch/steuernummer
```

Usage
-----

[](#usage)

### Normalize

[](#normalize)

```
normalizeSteuernummer('21/815/08150', 'BE'); // => '1121081508150'
```

or

```
use Rechtlogisch\Steuernummer\Normalize;

(new Normalize('21/815/08150', 'BE'))
    ->returnElsterSteuernummerOnly(); // => '1121081508150'
```

Tip

You can use `run()` instead, if you want more details.

### Denormalize

[](#denormalize)

```
denormalizeSteuernummer('1121081508150'); // => '21/815/08150'
```

or

```
use Rechtlogisch\Steuernummer\Denormalize;

(new Denormalize('1121081508150'))
    ->returnSteuernummerOnly(); // => '21/815/08150'
```

Tip

You can use `run()` instead, if you want more details.

#### Details

[](#details)

You can additionally control the result with setting `returnWithFederalState: true`. When set `true` information which federal state the Steuernummer origins from is being added to result.

```
denormalizeSteuernummer('1121081508150', returnWithFederalState: true);
// [
//   'steuernummer' => '21/815/08150',
//   'federalState' => 'BE',
// ]
```

or

```
use Rechtlogisch\Steuernummer\Denormalize;

(new Denormalize('1121081508150'))
    ->returnWithFederalState();
// [
//   'steuernummer' => '21/815/08150',
//   'federalState' => 'BE',
// ]
```

Tip

You can use `run()` instead, if you want even more details.

### Validate

[](#validate)

You can validate an input in the so called [ELSTER-Steuernummerformat](https://www.elster.de/eportal/helpGlobal?themaGlobal=wo_ist_meine_steuernummer#aufbauSteuernummer) (13-digits):

```
isElsterSteuernummerValid('1121081508150'); // => true
```

or by providing the so called [Bescheidformat](https://www.elster.de/eportal/helpGlobal?themaGlobal=wo_ist_meine_steuernummer#aufbauSteuernummer) (length varies) together with the federal state:

```
isSteuernummerValid('21/815/08150', 'BE'); // => true
```

Note

There are two functions `isElsterSteuernummerValid()` and `isSteuernummerValid()` depending on the format of your input.

#### Alternative

[](#alternative)

```
use Rechtlogisch\Steuernummer\Validate;

(new Validate('1121081508150'))
    ->run() // ValidationResult::class
    ->isValid(); // => true
```

The federal state is determined by the first digits of the ELSTER-Format, you can provide it as the second parameter to override the auto-determination:

```
use Rechtlogisch\Steuernummer\Validate;

(new Validate('1121081508150', 'BE'))
    ->run() // ValidationResult::class
    ->isValid(); // => true
```

Errors
------

[](#errors)

You can get a list of errors explaining why the provided input is invalid. The `run()` method on each class returns a DTO with a `getErrors()` method.

Note

The keys of `getErrors()` hold the stringified reference to the exception class. You can check for a particular error by comparing to the `::class` constant. For example: `Rechtlogisch\Steuernummer\Exceptions\InvalidElsterSteuernummerLength::class`.

### Validation errors

[](#validation-errors)

```
use Rechtlogisch\Steuernummer\Validate;

(new Validate('123456789012', 'BE'))
    ->run() // ValidationResult::class
    ->getErrors();
// [
//   'Rechtlogisch\Steuernummer\Exceptions\InvalidElsterSteuernummerLength'
//    => 'elsterSteuernummer must be 13 digits long. You provided: 12 digits.'
// ]
```

### Normalization errors

[](#normalization-errors)

```
use Rechtlogisch\Steuernummer\Normalize;

(new Normalize('123456789', 'BE'))
    ->run() // NormalizationResult::class
    ->getErrors();
// [
//   'Rechtlogisch\Steuernummer\Exceptions\InvalidSteuernummerLength'
//    => 'steuernummer for BE must contain exactly 10 digits. You provided: 9 digits.'
// ]
```

### Denormalization errors

[](#denormalization-errors)

```
use Rechtlogisch\Steuernummer\Denormalize;

(new Denormalize('123456789012'))
    ->run() // DenormalizationResult::class
    ->getErrors();
// [
//   'Rechtlogisch\Steuernummer\Exceptions\InvalidElsterSteuernummerLength'
//    => 'elsterSteuernummer must be 13 digits long. You provided: 12 digits.'
// ]
```

Note

All `*Result::class` extend the [ResultDto](./src/Abstracts/ResultDto.php).

### Supported tax offices

[](#supported-tax-offices)

By default, tax office codes (German: Bundesfinanzamtsnummer - short BUFA) included in the [ELSTER ERiC libraries](https://www.elster.de/elsterweb/infoseite/entwickler) are supported by this package. Currently, based on ERiC 41.5.4. You'll find the list in [src/Bufas.php](./src/Bufas.php).

The list includes test BUFAs, which are invalid in production. It is recommended to disable them in production with the following environment variable:

```
STEUERNUMMER_PRODUCTION=true
```

or in PHP:

```
putenv('STEUERNUMMER_PRODUCTION=true');
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/rechtlogisch/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Krzysztof Tomasz Zembrowski](https://github.com/rechtlogisch)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance62

Regular maintenance activity

Popularity28

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~85 days

Total

5

Last Release

336d ago

PHP version history (2 changes)v1.0.0PHP ^8.1

v1.2.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/4f60f360e9d79540ea00427585d1b0063f2c1125ef8d22be6939428ffb68ccc1?d=identicon)[rechtlogisch](/maintainers/rechtlogisch)

---

Top Contributors

[![zembrowski](https://avatars.githubusercontent.com/u/2451083?v=4)](https://github.com/zembrowski "zembrowski (19 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")

---

Tags

denormalizenormalizephpsteuernummertax-numbervalidatenormalizevalidategermanydenormalizetax numberrechtlogischsteuernummer

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rechtlogisch-steuernummer/health.svg)

```
[![Health](https://phpackages.com/badges/rechtlogisch-steuernummer/health.svg)](https://phpackages.com/packages/rechtlogisch-steuernummer)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[wixel/gump

A fast, extensible &amp; stand-alone PHP input validation class that allows you to validate any data.

1.2k1.3M30](/packages/wixel-gump)[inhere/php-validate

generic data validate, filter library of the php

26787.4k13](/packages/inhere-php-validate)[sadegh19b/laravel-persian-validation

A comprehensive Laravel validation package for Persian text, numbers, dates, and Iranian national identifiers

18293.8k1](/packages/sadegh19b-laravel-persian-validation)[abcaeffchen/sepa-utilities

SepaUtilities provides useful methods for validating and sanitizing inputs used in SEPA files supporting PHP &gt;= 8.1.

312.0M2](/packages/abcaeffchen-sepa-utilities)[awurth/slim-validation

A wrapper around the respect/validation PHP validation library for easier error handling and display

65378.4k9](/packages/awurth-slim-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
