Roman numerals encode numbers with seven letters — I, V, X, L, C, D, M — using addition and a limited subtractive rule. This converter turns any integer from 1 to 3999 into a correctly-formed numeral and parses numerals back to integers, rejecting malformed input.
How it works
Encoding uses a greedy table of value-symbol pairs, including the subtractive pairs, processed from largest to smallest:
1000 M 900 CM 500 D 400 CD
100 C 90 XC 50 L 40 XL
10 X 9 IX 5 V 4 IV
1 I
For each pair, the algorithm appends the symbol while the remaining value is
greater than or equal to that pair’s value, then subtracts it. Decoding scans
the string left to right: if a symbol’s value is less than the next symbol’s
value it is subtracted, otherwise it is added. To validate, the decoded integer
is re-encoded and compared to the original text — anything that does not match
exactly (such as IIII or IC) is reported as invalid.
Worked examples
The year 2024 becomes MMXXIV: two M’s for 2000, XX for 20, and IV for 4. The subtractive rule is strict — 99 is XCIX (90 + 9), never IC, because a smaller symbol may only precede the next one or two steps up in value. A few illustrative conversions:
| Integer | Roman numeral | Notes |
|---|---|---|
| 4 | IV | Not IIII |
| 14 | XIV | X + IV |
| 44 | XLIV | XL + IV |
| 99 | XCIX | XC + IX (not IC) |
| 2024 | MMXXIV | MM + XX + IV |
| 3999 | MMMCMXCIX | Maximum value |
Where Roman numerals are still used
The converter is useful for a surprising range of practical needs:
- Clock faces — most Roman-numeral clocks use IIII for 4 (not IV) by historical convention, though IV appears on some; the validator flags IIII as non-standard
- Film and TV copyright dates — studios have required Roman copyright years in credits, making 2024 → MMXXIV a common real-world conversion
- Book front matter — preface and introduction pages are typically numbered in lowercase Roman numerals (i, ii, iii, iv…)
- Monarchs and popes — Elizabeth II, Pope John XXIII, and similar regnal names
- Super Bowl and Olympic numbering — Super Bowl LVIII, the XXXIII Olympiad
The converter handles all of these cases. Lowercase input (mcmxcix) is accepted and uppercased automatically; output is always uppercase per the standard convention.