Roman Numeral Converter

Enter text in one box, and it will be converted into the other box. Type a dash in the Roman Numeral box to add a vinculum over the previous letter.


Roman numerals are one of the world's most enduring number systems. After more than 2,000 years, they're still commonplace.

Numbers are represented by sequences of capital letters in the Latin alphabet. The values of each letter are added or subtracted to create a number. Letters with lesser values are subtracted if they occur before letters with greater values. Otherwise, they are added. For example, VI = 6, but IV = 4. Put a vinculum (horizontal bar) over a letter to multiply it by 1,000. For example, is 1,000,000.

RomanDecimal
I1
V5
X10
L50
C100
D500
M1,000

This yields a large amount of freedom in the representation of a number. For example, 54 is LIV, but so is LIIII. The modern standard guarantees a unique representation for every number by specifying that at most one subtracted letter may exist for each unique added letter, and each base-10 digit position must be constructed separately. Put simply, the values IV = 4, IX = 9, XL = 40, XC = 90, CD = 400, and CM = 900, are treated as their own indivisible "letters" and used with the other letters to construct a number with purely additive operations, as if counting coin change with a greedy algorithm (pick the largest possible coins first, until they don't fit, and then go to the next smaller coin).

If you ever find yourself in an ancient Roman tailor's shop, be careful! Size XL is smaller than L.


Despite the modern standard, the ultimate authoritative source on Roman numerals - the Roman Empire - used LIIII for entrance 54 on the Colosseum! They consistently avoided IV for 4, while still using other subtractive forms, like XL for entrance 40.

The Roman Colosseum.
LIIII carved above one of the Colosseum's arched entrances.XL carved above one of the Colosseum's arched entrances.

The Emperor Vespasian had the Colosseum constructed between 70 and 80 A.D. During that same period of Roman history, IV was happily used on the street signs in ancient Pompeii (which Mount Vesuvius entombed in 79 A.D.), such as this sign for Regio 6, Insula 14:

A street sign in Pompeii, saying REG.VI.INS.XIV in red letters engraved and painted on a white marble tile, cemented on a red brick wall.

Given this freedom in when and where to use subtracted letters, one can minimize the number of letters needed to represent a number. For example, 99 is XCIX in standard form, but is just IC in its shortest possible form. A simple algorithm to convert into the shortest form involves counting with both positive and negative units, taking the largest step possible as in the standard-form algorithm, and ordering the letters based on their sign so the Roman numeral is correct.

The source code is available here.