Convert Roman Numerals to Arabic Numbers

JavaScript used to convert given roman numerals to its equivalent arabic numbers. Simply enter the roman value in the appropriate space below and click on the Convert button.


  • Used to display the numeric arabic value of the given roman numerals.
  • Provides easy accessibility.


Roman Number:
Numeric Value:


Javascript Code

<!-- Script by -->
<!-- More scripts -->
<style type="text/css">
.txt{border:1px solid grey;width:150px;height:25px;font-size:12px;padding:5px;font-family:arial,verdana;}
<script type="text/javascript">
var rarr = new Array("M",
"CM", "D", "CD", "CCC", "CC", "C", "XC", "L", "XL", "XXX", "XX", "X", "IX", "V", "IV", "III", "II", "I");var narr = new Array(1000,900,500,400,300,200,100,90,50,40,30,20,10,9,5,4,3,2,1); var warr = new Array("CMCM",
"CMCD", "CMC", "DD", "DCD", "CDCD", "CDC", "CCCC", "XCXC",
"XCL", "XCXL", "XCX", "LL", "LXL", "XLXL", "XLX", "XXXX", "IXIX",
"IXV", "IXIV", "IXI", "IVIV", "IVI", "IIII");var carr= new Array("MDCCC", "MCD",
"MIII", "M",
"DCCC", "D",
"CLXXX", "CXL", "CIII", "C",
"LXXX", "L",
"XVIII", "XIV", "XIII", "X",
"VIII", "V",
function convert_numeric()
{var rom = document.getElementById("roman").value;var roman = rom.replace(/ /g, "");roman = roman.toUpperCase();roman = roman.replace(/[^IVXLCDM]/g, "");document.getElementById("roman").value=roman;if (roman.length == 0){document.getElementById("res").innerHTML = "";return;}var position = 0;var result = 0;var pp = -1;while(position < roman.length){var p = getnextletter(roman, position);if (pp != 0){if ( narr[pp] < narr[p] ){document.getElementById("res").innerHTML = "Error. "+rarr[p]+" should not follow "+rarr[pp];return;}}if(p < 0)return;position += rarr[p].length;result += narr[p];pp = p;}document.getElementById("res").innerHTML =
function getnextletter(roman, position)
{for (i=0; i<warr.length; i++){if ( roman.indexOf(warr[i], position) == position ){document.getElementById("res").innerHTML = warr[i] + " is not correct replace with " + carr[i] + ".";return -1;}}for (i=0; i<rarr.length; i++){if ( roman.indexOf(rarr[i], position) == position)return i;}document.getElementById("res").innerHTML = "invalid at " +position;return -1;
</script><!-- Script by -->


<tr><td class="fnt">Roman Number:</td><td><input type="text"
class="txt" id="roman" value="" onkeyup="convert_numeric()"></td></tr>
<tr><td class="fnt">Numeric Value:</td><td class="fnt"><div id="res" style='border:1px solid grey;height:22px; padding: 2px; padding-left: 8px;'></div></td></tr>
<tr><td colspan=2><div align=center style="font-size: 10px; color:green;" id="dumdiv">
<a href="" id="dum" style="text-decoration:none; color: #dadada;">&copy;h</a>

  • Release Date - 06-05-2010
  • Get free version without ©copyright link for just $10/-
  • For customization of this script or any script development, mail to


  • Copy and paste the javascript code into your HTML page and make use of this.
  • Here, the function "convert_numeric()" is used to convert roman numerals to arabic numbers.


Related Scripts

Free Javascript Scripts

Ask Questions

Ask Question