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 🙏

© 2025 – Pkg Stats / Ryan Hefner

soff-id

v0.2.1

Published

LATAM document validation library - Validate NIT, RUT, CPF, CUIT, and more

Readme

npm License Build Status codecov minzipped size


Zero dependencies · TypeScript · ~1KB per locale

Table of Contents

🤔 Why?

Validating identity documents in LATAM is something every developer in the region has to implement:

| Country | Documents | Complexity | | ------------ | --------------- | ------------------------ | | 🇨🇴 Colombia | NIT, CC, CE, TI | ✅ Check digit algorithm | | 🇧🇷 Brasil | CPF, CNPJ | ✅ Two check digits | | 🇦🇷 Argentina | DNI, CUIT, CUIL | ✅ Modulus 11 | | 🇨🇱 Chile | RUT, RUN | ✅ Check digit with 'K' | | 🇲🇽 México | RFC, CURP | ✅ Complex validation |

This library provides official algorithms in a modular, tree-shakeable way. Import only what you need! 🌳

📦 Install

# npm
npm install soff-id

# pnpm
pnpm add soff-id

# yarn
yarn add soff-id

# bun
bun add soff-id

🚀 Quick Start

// Only Colombia included in bundle (~1KB)
import { validateNIT, formatNIT, calculateNITCheckDigit } from 'soff-id/locales/co';

// ✅ Validate NIT
validateNIT('900123456-7'); // → true

// 🧠 Calculate check digit
calculateNITCheckDigit('900123456'); // → '7'

// 🎨 Format NIT
formatNIT('9001234567'); // → '900.123.456-7'

Multi-country Usage

import { validateCPF, validateCNPJ } from 'soff-id/locales/br';
import { validateRUT } from 'soff-id/locales/cl';
import { validateCUIT } from 'soff-id/locales/ar';
import { validateRFC } from 'soff-id/locales/mx';

// Brazilian CPF
validateCPF('123.456.789-09'); // → true/false

// Chilean RUT
validateRUT('12.345.678-5'); // → true/false

// Argentine CUIT
validateCUIT('20-12345678-9'); // → true/false

// Mexican RFC
validateRFC('XAXX010101000'); // → true/false

Available Locales

| Locale | Import | Documents | Description | | ------------ | -------------------- | --------------- | ----------------------------------------- | | 🇨🇴 Colombia | soff-id/locales/co | NIT, CC, CE, TI | Tax ID, Cédula, Foreign ID, Identity Card | | 🇧🇷 Brasil | soff-id/locales/br | CPF, CNPJ | Individual & Business Tax IDs | | 🇦🇷 Argentina | soff-id/locales/ar | DNI, CUIT, CUIL | National ID & Tax IDs | | 🇨🇱 Chile | soff-id/locales/cl | RUT, RUN | Tax ID & National ID | | 🇲🇽 México | soff-id/locales/mx | RFC, CURP | Tax ID & Personal ID |

API Reference

Each locale exports a consistent set of functions for each document type:

validate{DOC}(value)

Validates if the document is valid.

import { validateNIT } from 'soff-id/locales/co';

validateNIT('900123456-7'); // → true
validateNIT('900123456-0'); // → false (wrong check digit)

format{DOC}(value)

Formats the document with proper separators.

import { formatNIT } from 'soff-id/locales/co';

formatNIT('9001234567'); // → '900.123.456-7'

clean{DOC}(value)

Removes all formatting from the document.

import { cleanNIT } from 'soff-id/locales/co';

cleanNIT('900.123.456-7'); // → '9001234567'

calculate{DOC}CheckDigit(value)

Calculates the check digit (where applicable).

import { calculateNITCheckDigit } from 'soff-id/locales/co';

calculateNITCheckDigit('900123456'); // → '7'

Bundle Size

| Import | Size (minified) | | ------------ | --------------- | | locales/co | ~1.1KB | | locales/br | ~1.0KB | | locales/ar | ~1.0KB | | locales/cl | ~0.8KB | | locales/mx | ~1.3KB | | Core only | ~0.5KB |

Tree-shaking ensures you only ship what you import.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation