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

@rdnr/num2es

v0.2.0

Published

Convierte números a palabras en español. Soporta monedas, géneros y escalas hasta trillones.

Downloads

220

Readme

num2es

npm

Convierte números a palabras en español. Sin dependencias externas, funciona en cualquier entorno JavaScript moderno y está optimizada para ser eficiente.

Nació como solución para ese problema clásico de entrevistas técnicas. La diferencia: trata el español correctamente con género gramatical, monedas de la región, escala larga y los casos especiales que otras librerías suelen ignorar.

Instalación

pnpm install num2es

Uso básico

import { numeroALetras } from 'num2es';

numeroALetras(0)         // "cero"
numeroALetras(42)        // "cuarenta y dos"
numeroALetras(100)       // "cien"
numeroALetras(101)       // "ciento uno"
numeroALetras(1000)      // "mil"
numeroALetras(1234)      // "mil doscientos treinta y cuatro"
numeroALetras(1000000)   // "un millón"
numeroALetras(-5)        // "menos cinco"
numeroALetras(3.14)      // "tres con catorce"

Con moneda

Acepta cualquier código ISO 4217 de la región. La gramática se ajusta automáticamente, incluyendo preposiciones que suelen olvidarse en números grandes.

numeroALetras(1234.56, { moneda: 'MXN' })
// → "mil doscientos treinta y cuatro pesos con cincuenta y seis centavos"

numeroALetras(1, { moneda: 'USD' })
// → "un dólar"

numeroALetras(2.5, { moneda: 'EUR' })
// → "dos euros con cincuenta céntimos"

// Este caso suele fallar en otras librerías:
numeroALetras(21000000, { moneda: 'USD' })
// → "veintiún millones de dólares"

Moneda personalizada

Puedes definir la tuya:

import type { MonedaConfig } from 'num2es';

const miMoneda: MonedaConfig = {
  singular:     'franco',
  plural:       'francos',
  centSingular: 'céntimo',
  centPlural:   'céntimos',
};

numeroALetras(1.5, { moneda: miMoneda })
// → "un franco con cincuenta céntimos"

Género gramatical

El español tiene género y esta librería lo sabe. Útil cuando el número acompaña a un sustantivo femenino.

numeroALetras(1,   { femenino: true })  // "una"
numeroALetras(21,  { femenino: true })  // "veintiuna"
numeroALetras(200, { femenino: true })  // "doscientas"
numeroALetras(31,  { femenino: true })  // "treinta y una"

Todas las opciones

interface OpcionesConversion {
  /** Usar formas femeninas (una, doscientas…). Por defecto: false */
  femenino?: boolean;

  /** Código ISO 4217 o configuración personalizada */
  moneda?: MonedaCodigo | MonedaConfig;

  /** Palabra entre la parte entera y los centavos. Por defecto: "con" */
  separadorDecimal?: string;
}

Monedas soportadas

Cubre toda la región hispanohablante más las divisas internacionales más comunes.

| Código | Moneda | |--------|-------------------| | MXN | Peso mexicano | | USD | Dólar | | EUR | Euro | | COP | Peso colombiano | | ARS | Peso argentino | | PEN | Sol peruano | | CLP | Peso chileno | | VES | Bolívar | | GTQ | Quetzal | | HNL | Lempira | | NIO | Córdoba | | CRC | Colón | | PAB | Balboa | | BOB | Boliviano | | PYG | Guaraní | | UYU | Peso uruguayo | | DOP | Peso dominicano | | CUP | Peso cubano |

Escala numérica

Usa la escala larga, que es el estándar en español. Si te preguntaste por qué en español un billón no es lo mismo que un billion en inglés, aquí está la explicación.

| Valor | Nombre | |-------|--------------| | 10³ | mil | | 10⁶ | millón | | 10⁹ | mil millones | | 10¹² | billón | | 10¹⁵ | mil billones | | 10¹⁸ | trillón |

Compatibilidad

Funciona donde corra JavaScript, sin configuración adicional:

  • Node.js ≥ 14 con ESM y CJS
  • React, Vue, Svelte — cualquier framework moderno
  • Bundlers: Vite, Webpack, esbuild
  • Browser directo vía CDN ESM
  • Cero dependencias de producción