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

cuit

v2.0.0

Published

Lightweight utilities for validating, formatting, and generating Argentine CUIT/CUIL numbers

Readme

cuit

npm version npm downloads CI License: MIT

Lightweight utilities for validating, formatting, and generating Argentine CUIT/CUIL numbers.

What is a CUIT?

CUIT (Clave Única de Identificación Tributaria) is Argentina's tax identification number. It's an 11-digit number with the format XX-XXXXXXXX-X:

  • First 2 digits: Type prefix (20/23/24 = male, 27 = female, 30/33/34 = company)
  • Middle 8 digits: DNI (national ID) or company registration number
  • Last digit: Check digit (mod 11 algorithm)

Installation

npm install cuit
pnpm add cuit
bun add cuit

Usage

import { isValid, generate, format, normalize } from "cuit";

// Validate a CUIT
isValid("20-12345678-6"); // true
isValid("20-12345678-0"); // false (wrong check digit)
isValid("20123456786");   // true (works without separators)

// Generate a CUIT from a DNI
generate("12345678", "M"); // "20123456786" (male)
generate("12345678", "F"); // "27123456781" (female)
generate("12345678", "E"); // "30123456786" (entity/company)

// Format a CUIT
format("20123456786");      // "20-12345678-6"
format("20123456786", "/"); // "20/12345678/6"
format("20123456786", "");  // "20123456786"

// Normalize (remove separators)
normalize("20-12345678-6"); // "20123456786"

API

isValid(input: string): boolean

Validates whether a CUIT is valid using the mod 11 algorithm.

isValid("20-12345678-6"); // true
isValid("invalid");       // false
isValid("20123456780");   // false (wrong check digit)

generate(dni: string, type: EntityType): string

Generates a valid CUIT from a DNI and entity type.

  • dni - The DNI number (8 digits, can include separators)
  • type - "M" (male), "F" (female), or "E" (entity/company)
generate("12345678", "M"); // "20123456786"
generate("12.345.678", "F"); // "27123456781" (separators are stripped)
generate("1234567", "M"); // "20012345672" (short DNIs are padded)

format(input: string, separator?: string): string

Formats a CUIT with the specified separator (default: "-").

format("20123456786");      // "20-12345678-6"
format("20123456786", "/"); // "20/12345678/6"
format("20123456786", " "); // "20 12345678 6"
format("20123456786", "");  // "20123456786"

normalize(input: string): string

Removes all non-digit characters from the input.

normalize("20-12345678-6"); // "20123456786"
normalize("20.12345678.6"); // "20123456786"

getPrefix(input: string): string

Extracts the 2-digit prefix from a CUIT.

getPrefix("20-12345678-6"); // "20"

getDni(input: string): string

Extracts the 8-digit DNI from a CUIT.

getDni("20-12345678-6"); // "12345678"

getCheckDigit(input: string): string

Extracts the check digit from a CUIT.

getCheckDigit("20-12345678-6"); // "6"

getEntityType(input: string): EntityType | null

Determines the entity type from a CUIT prefix.

getEntityType("20-12345678-6"); // "M" (male)
getEntityType("27-12345678-1"); // "F" (female)
getEntityType("30-12345678-6"); // "E" (entity)
getEntityType("99-12345678-0"); // null (unknown prefix)

Types

type EntityType = "M" | "F" | "E";
type CuitPrefix = "20" | "23" | "27" | "30";

Features

  • Zero dependencies
  • Full TypeScript support
  • Works in Node.js, browsers, and edge runtimes
  • ESM and CommonJS support
  • Tree-shakeable
  • Tiny bundle size (~800 bytes gzipped)

License

MIT