Generator · Swedish data

Swedish organisationsnummer

Endpoint GET /v1/se/organisationsnummer

What it covers

Returns a valid Swedish organisationsnummer (legal-entity identifier) with a correct Luhn check digit. Use `format` for the SE VAT number. Set `invalid=true` for a number with a deliberately wrong check digit.

How it’s calculated

The 10th digit of a Swedish organisationsnummer is a Luhn (mod-10) check digit over the nine preceding payload digits.

Algorithm

  1. Take the nine payload digits d1 d2 d3 d4 d5 d6 d7 d8 d9 (the check digit is NOT yet appended). d1 is 1-9 (entity-type group), d3 is >= 2, the rest are 0-9.
  2. Process the payload from right to left. Set an alternating flag 'doubling' = true for the rightmost payload digit (d9), then flip it on every subsequent digit (so d9, d7, d5, d3, d1 are doubled; d8, d6, d4, d2 are taken as-is).
  3. For each digit: if 'doubling' is true, multiply the digit by 2, and if the product exceeds 9 subtract 9 (equivalently, add the two decimal digits of the product).
  4. Add every resulting value into a running sum.
  5. Compute the check digit as (10 - (sum mod 10)) mod 10. The outer mod 10 makes a residue of 0 yield check digit 0 rather than 10.
  6. Append this check digit as the 10th digit to form the canonical 10-digit organisationsnummer. (The 'vat' format then wraps it as SE + the 10 digits + 01.)

Worked example

Organisationsnummer 16556123 4-? (payload 165561234, check digit ?)

Payload digits, left to right (indices 0-8): 1, 6, 5, 5, 6, 1, 2, 3, 4.
Process right to left; rightmost (4) is doubled, then alternate.
4 doubled = 8.
3 as-is = 3.
2 doubled = 4.
1 as-is = 1.
6 doubled = 12 -> 12-9 = 3.
5 as-is = 5.
5 doubled = 10 -> 10-9 = 1.
6 as-is = 6.
1 doubled = 2.
Sum = 8 + 3 + 4 + 1 + 3 + 5 + 1 + 6 + 2 = 33.
Check digit = (10 - (33 mod 10)) mod 10 = (10 - 3) mod 10 = 7.

The check digit is 7, giving the full organisationsnummer 1655612347.

Edge cases

  • Zero check digit: when the Luhn residue is 0, the check digit is 0 (the (10 - sum%10) % 10 outer mod handles this). A naive numeric parse that drops a trailing zero would mangle such a number.
  • Minimum third digit: d3 = 2 is the smallest legal value (the historic 'month pair' >= 20 that separates organisations from personnummer).
  • Entity-type group: d1 ranges 1-9; leading zero is never produced, so the first digit is always significant.

Gotchas

  • This is plain Luhn — no per-position weight vector is passed to luhnCheckDigit; the weights are Luhn's implicit alternating 2,1,2,1,... applied from the rightmost payload digit inward.
  • The rightmost PAYLOAD digit (d9) is the first to be doubled. Because the check digit is not part of the payload here, doubling starts 'true'; validation over the full 10 digits instead starts 'false' (isValidLuhn).
  • The generator's Luhn only checks the checksum; it does NOT verify the entity actually exists in Bolagsverket's register — values are structurally valid but synthetic.

Parameters

ParameterTypeDescription
countinteger1–1000Number of records to return, 1–1000 (your plan may lower this). Omitted returns a single record; set it for a batch.
edgebooleanRestrict output to valid edge-case organisationsnummer from the rare corners.
extremebooleanReturn a correct value wrapped in a hostile encoding (untrimmed whitespace, invisible/zero-width characters, BOM, or bidi/combining marks). Homoglyphs are excluded so the value stays machine-parseable; it still validates after normalisation.
format"national" | "vat"Rendering: bare 10-digit national number (default) or SE VAT number.
invalidbooleanReturn a number with a deliberately wrong Luhn check digit.
seedintegerInteger seed for reproducible output: the same seed always yields the same record.

Response fields

FieldTypeDescription
valuestringThe identifier in the requested format (national or VAT).
digitsstringThe canonical, unprefixed 10-digit number.

Other generators for Sweden

See all generators for Sweden →

The same kind of identifier elsewhere

Try it

Generate a live example below — every response is valid by format and entirely synthetic.