Roman Numeral Converter

Convert between Arabic numbers and Roman numerals.

Decimal → Roman

Roman → Decimal

Roman Numeral Reference

I

1

V

5

X

10

L

50

C

100

D

500

M

1000

IV = 4
IX = 9
XL = 40
XC = 90
CD = 400
CM = 900

Code Examples

function toRoman(num) {
  const map = [
    ['M',1000],['CM',900],['D',500],['CD',400],
    ['C',100],['XC',90],['L',50],['XL',40],
    ['X',10],['IX',9],['V',5],['IV',4],['I',1]
  ];
  let result = '';
  for (const [roman, value] of map) {
    while (num >= value) {
      result += roman;
      num -= value;
    }
  }
  return result;
}

Frequently Asked Questions

How do Roman numerals work?

I=1, V=5, X=10, L=50, C=100, D=500, M=1000. Add values left to right, except when a smaller value precedes a larger (IV=4, IX=9, XL=40, XC=90, CD=400, CM=900).

What's the largest Roman numeral?

Standard notation goes up to 3999 (MMMCMXCIX). For larger numbers, a bar over a numeral multiplies by 1000 (V̄ = 5000), but this isn't commonly used.

Related Tools