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.
Example and tips
The year 2024 becomes MMXXIV: two M’s for 2000, XX for 20, and IV for 4. Note that the subtractive rule is strict — 99 is XCIX (90 + 9), never IC, because a smaller symbol may only precede the next one or two sizes up. The tool enforces this so the numerals you copy are valid for clock faces, book chapters, film copyright dates, and monument inscriptions.