DevToolBox

Roman Numeral Converter

1〜3999のアラビア数字と標準的なローマ数字を、減算記法に対応して相互変換します。

How to Use the Roman Numeral Converter

Select a direction, enter an integer from 1 through 3999 or a Roman numeral, and press Convert. Lowercase input is normalized. Canonical notation makes 4 IV, not IIII, and 1994 MCMXCIV.

Symbols and the greedy algorithm

The seven symbols are I=1, V=5, X=10, L=50, C=100, D=500, and M=1000. Encoding repeatedly removes the largest value. Including CM, CD, XC, XL, IX, and IV in the descending table produces subtractive notation.

Canonical validation

Modern notation permits only six subtractive pairs. Thus IL is not valid for 49; use XLIX. This tool decodes and then re-encodes input, rejecting ambiguous forms such as VX and IIV.

History and modern usage

Roman numerals evolved from ancient tally-like notation and varied across inscriptions. Normalized modern rules are unambiguous. They remain visible on clocks, book chapters and front matter, film years, monarch names, and events such as the Super Bowl.

使い方

変換方向を選び、1〜3999の整数またはローマ数字を入力して「変換」を押します。小文字も入力できます。944はCMXLIV、2026はMMXXVIです。

標準表記と3999という上限

I・X・C・Mは原則3回まで連続でき、V・L・Dは繰り返しません。4000以上の上線記法はUnicodeや組版上の表現が一定しないため対象外です。0や負数を表す古典的な標準記号もありません。

時計・書籍・映画での違い

時計の4時には装飾的なIIIIもありますが、本ツールの正規形はIVです。書籍の前付け、映画の制作年、Super Bowlなどの回数表記にも使われます。

よくあるエラーと対処 / Common Errors and Fixes

症状 / Symptom原因 / Cause対処 / Fix
0や4000でエラー / rejected標準範囲外 / Out of range1〜3999を入力 / Enter 1–3999
IIIIが拒否 / rejected時計用の異表記 / Clock variantIVを使用 / Use IV
ILやICが拒否 / rejected無効な減算ペア / Invalid pairXLIX、XCIXを使用 / Use canonical form
Nを入力できない / not accepted標準7記号ではない / Nonstandard symbol1以上を使用 / Use at least 1

言語別コード例 / Code Examples

JavaScript

function roman(n, pairs) { let s=""; for(const [v,c] of pairs) while(n>=v){s+=c;n-=v} return s; }

Python

def roman(n, pairs):
    out = ""
    for value, symbol in pairs:
        count, n = divmod(n, value)
        out += symbol * count
    return out

Go

func roman(n int, values []int, symbols []string) string {
 var b strings.Builder
 for i, v := range values { for n >= v { b.WriteString(symbols[i]); n -= v } }
 return b.String()
}

各例ではPAIRSと同じ降順表を渡し、呼び出し前に1〜3999の範囲を検証します。

Before / After 実例

4 → IV
9 → IX
49 → XLIX
944 → CMXLIV
1994 → MCMXCIV
MMXXVI → 2026

900→CM、40→XL、4→IVの順で適用するため、944は短く一意なCMXLIVになります。

Why browser-only? / なぜブラウザ完結か

Every conversion and canonical check runs locally in deterministic JavaScript. No input is uploaded, logged, or shared with an external API, which suits unpublished chapters, film credits, and internal event plans.

変換と検証はブラウザ内で実行され、入力を外部APIへ送信せずサーバーログにも残しません。未公開の章構成やイベント回次も外部へ渡さず確認できます。

関連ツール・関連ガイド

開発をもっと効率的に

PR