Generator · Croatian data
Croatian JMBG
Endpoint GET /v1/hr/jmbg
What it covers
Returns a historically well-formed Croatian JMBG (replaced by the OIB in 2009) with a correct mod-11 check. Constrain with `sex` and age/birth-date filters; the JMBG encodes the full birth date. Contradictory combinations are rejected with a 400. Set `invalid=true` for a deliberately failing check.
How it’s calculated
The 13th digit of a Croatian JMBG is a weighted mod-11 check over the first 12 digits, taken as the 11-complement of the remainder, with residue 0 mapping to check 0 and residue 1 (which would require an unrepresentable check of 10) being rejected and redrawn.
Algorithm
- Assemble the 12-digit payload in order: DD (2-digit day of birth) + MM (2-digit month) + YYY (last 3 digits of the birth year, i.e. year mod 1000) + RR (2-digit region code, 30-39 for Croatia) + BBB (3-digit serial; 000-499 male, 500-999 female). Example layout: D1 D2 M1 M2 Y1 Y2 Y3 R1 R2 B1 B2 B3.
- Take those 12 digits as numbers d[0..11] left to right.
- Apply the fixed position weights W = [7, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3, 2] (two descending 7..2 runs).
- Compute the weighted sum S = sum over i of d[i] * W[i]. No intermediate modulo is applied inside the sum.
- Compute the remainder r = S mod 11.
- If r == 0, the check digit is 0.
- If r == 1, the check digit would have to be 10, which is not a single digit; this payload is invalid — reject it and pick a different serial (the generator redraws region+serial and retries).
- Otherwise (r is 2..10), the check digit is 11 - r.
- Append the single check digit as the 13th and final digit of the JMBG.
Worked example
JMBG for a male born 15 June 1985, region 33, serial 142: 150698533142? (check digit unknown)
Payload digits (DDMMYYY RR BBB): 15 06 985 33 142 -> 1 5 0 6 9 8 5 3 3 1 4 2
Weights: 7 6 5 4 3 2 7 6 5 4 3 2
Products: 1*7=7, 5*6=30, 0*5=0, 6*4=24, 9*3=27, 8*2=16, 5*7=35, 3*6=18, 3*5=15, 1*4=4, 4*3=12, 2*2=4
Sum S = 7+30+0+24+27+16+35+18+15+4+12+4 = 192
Remainder r = 192 mod 11 = 5 (11*17 = 187, 192-187 = 5)
r is neither 0 nor 1, so check = 11 - r = 11 - 5 = 6The check digit is 6, giving the full JMBG 1506985331426.
Edge cases
- Residue r == 1 has no valid single-digit check (it would be 10); the generator never emits such a number — it redraws the region and serial and retries the whole build.
- Residue r == 0 yields check digit 0 (not 11), a distinct branch from the general 11 - r rule.
- The 3-digit year field is year mod 1000, so a century marker is not stored explicitly (985 -> 1985); this generator only encodes 1900-2099 births.
Gotchas
- The weighted sum is NOT reduced mod 11 per digit; weightedSum returns the raw dot product and the single % 11 is applied afterward in build-jmbg.ts.
- The serial band encodes sex, not a separate digit: 000-499 = male, 500-999 = female (FEMALE_SERIAL_START = 500). It participates in the checksum like any other payload digit.
- Region digits RR must be 30-39 for Croatia; the check-digit math itself does not validate the region, only the format assembly does.
Parameters
| Parameter | Type | Description |
|---|---|---|
| atAge | integer | Exact age in years at request time. |
| bornAfter | stringpattern ^\d{4}(?:-\d{2}(?:-\d{2})?)?$ | Born after this date or fragment (YYYY, YYYY-MM, YYYY-MM-DD). |
| bornBefore | stringpattern ^\d{4}(?:-\d{2}(?:-\d{2})?)?$ | Born before this date or fragment (YYYY, YYYY-MM, YYYY-MM-DD). |
| bornOn | stringpattern ^\d{4}(?:-\d{2}(?:-\d{2})?)?$ | Born on a date or within a fragment: YYYY, YYYY-MM, or YYYY-MM-DD. |
| count | integer1–1000 | Number of records to return, 1–1000 (your plan may lower this). Omitted returns a single record; set it for a batch. |
| edge | boolean | Restrict output to edge-case values. |
| extreme | boolean | Return 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. |
| invalid | boolean | Return a JMBG with a deliberately failing mod-11 check; birth date/sex stay valid. |
| olderThan | integer | Minimum age in years at request time. |
| seed | integer | Integer seed for reproducible output: the same seed always yields the same record. |
| sex | "m" | "f" | Encoded sex: "m" or "f". |
| youngerThan | integer | Maximum age in years at request time. |
Response fields
| Field | Type | Description |
|---|---|---|
| value | string | The 13-digit JMBG. |
| digits | string | The canonical 13-digit JMBG. |
| birthDate | string | The encoded birth date, ISO `YYYY-MM-DD`. |
| sex | "m" | "f" | Encoded sex: `m` (serial 000–499) or `f` (serial 500–999). |
Other generators for Croatia
The same kind of identifier elsewhere
Try it