npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

roman-numerals-js

v1.0.1

Published

A lightweight, robust TypeScript library for Roman Numerals conversion. Powered by roman-numerals.com

Readme

roman-numerals-js

A lightweight, robust TypeScript library for converting between integers and Roman numerals. Built with modern JavaScript (ES6+) and full TypeScript support.

Powered by roman-numerals.com - Visit for more online conversion tools, historical information, and comprehensive Roman numerals resources.

Features

  • 🚀 Fast and efficient conversion algorithms
  • 💪 Full TypeScript support with type definitions
  • ✅ Comprehensive input validation
  • 🎯 Supports numbers from 1 to 3999
  • 📦 Zero dependencies
  • 🔄 Bidirectional conversion (Integer ↔ Roman)
  • ✨ Works in both Node.js and browser environments

Installation

npm install roman-numerals-js

Or using yarn:

yarn add roman-numerals-js

Usage

ES6 Modules

import { toRoman, fromRoman } from 'roman-numerals-js';

// Convert integer to Roman numerals
console.log(toRoman(2024));  // Output: "MMXXIV"
console.log(toRoman(1994));  // Output: "MCMXCIV"

// Convert Roman numerals to integer
console.log(fromRoman('IX'));      // Output: 9
console.log(fromRoman('LVIII'));   // Output: 58

CommonJS

const { toRoman, fromRoman } = require('roman-numerals-js');

console.log(toRoman(42));         // Output: "XLII"
console.log(fromRoman('CDXC'));   // Output: 490

API Reference

toRoman(num: number): string

Converts an integer to Roman numerals.

Parameters:

  • num (number): An integer between 1 and 3999

Returns:

  • (string): The Roman numeral representation

Throws:

  • Error if the number is not an integer or is outside the valid range (1-3999)

Examples:

toRoman(1);     // "I"
toRoman(4);     // "IV"
toRoman(9);     // "IX"
toRoman(58);    // "LVIII"
toRoman(1994);  // "MCMXCIV"
toRoman(3999);  // "MMMCMXCIX"

fromRoman(str: string): number

Converts Roman numerals to an integer.

Parameters:

  • str (string): A valid Roman numeral string (case-insensitive)

Returns:

  • (number): The integer value

Throws:

  • Error if the string contains invalid characters or format

Examples:

fromRoman('I');        // 1
fromRoman('IV');       // 4
fromRoman('ix');       // 9 (case-insensitive)
fromRoman('LVIII');    // 58
fromRoman('MCMXCIV');  // 1994

Validation Rules

  • Input numbers must be integers between 1 and 3999
  • Roman numeral strings must contain only valid characters: I, V, X, L, C, D, M
  • The library automatically handles case conversion (accepts both uppercase and lowercase)
  • Leading and trailing whitespace is automatically trimmed

More Resources

For more information about Roman numerals, including:

  • Interactive online conversion tools
  • Historical background and usage
  • Educational materials and examples
  • Comprehensive conversion tables

Visit roman-numerals.com - your complete resource for everything related to Roman numerals.

Development

# Install dependencies
npm install

# Run tests
npm test

# Run tests in watch mode
npm run test:watch

# Generate coverage report
npm run test:coverage

# Build the library
npm run build

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


Learn more at roman-numerals.com