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

@kodatec/brasil-utils

v1.0.0

Published

Utilitários para dados brasileiros: formatação, validação e máscaras de CPF, CNPJ, CEP, telefone, moeda e mais.

Readme

@kodatec/brasil-utils

Utilitarios para dados brasileiros: formatacao, validacao e mascaras de CPF, CNPJ, CEP, telefone, moeda e mais.

  • TypeScript com tipos inclusos
  • ESM e CommonJS
  • Zero dependencias em runtime
  • Configuracoes de mascara compativeis com IMask

Instalacao

npm install @kodatec/brasil-utils

Uso

import {
  validarCPF,
  formataCpf,
  maskCpf,
  getUfs,
} from '@kodatec/brasil-utils'

API

Validacao

| Funcao | Descricao | |---|---| | validarCPF(cpf) | Valida CPF (aceita com ou sem mascara) | | validarCNPJ(cnpj) | Valida CNPJ (aceita com ou sem mascara) | | isValidDate(dateString) | Valida data no formato DD/MM/YYYY | | isValidDateMesAno(dateString) | Valida mes/ano no formato MM/YYYY |

validarCPF('123.456.789-09') // true | false
validarCNPJ('11.222.333/0001-81') // true | false
isValidDate('31/12/2025') // true
isValidDateMesAno('13/2025') // false

Formatacao

Documentos

| Funcao | Descricao | |---|---| | formataCpf(cpf, mascarar?) | Formata CPF. mascarar=true (padrao) oculta digitos: ***.456.789-** | | formataCnpj(cnpj, mascarar?) | Formata CNPJ. mascarar=false (padrao) exibe completo | | formataNis(nis) | Formata NIS/PIS/PASEP: 123.45678.90-1 | | formataCep(cep) | Formata CEP: 12345-678 | | formataTelefone(telefone) | Formata telefone fixo ou celular: (11) 99999-9999 |

formataCpf('12345678909')        // '***.$2.$3-**'
formataCpf('12345678909', false) // '123.456.789-09'
formataCnpj('11222333000181')    // '11.222.333/0001-81'
formataTelefone('11999998888')   // '(11) 99999-8888'

Moeda

| Funcao | Descricao | |---|---| | formataMoedaReais(valor) | Formata numero para moeda BRL: R$ 1.234,56 |

formataMoedaReais(1234.5) // 'R$ 1.234,50'

Nomes

| Funcao | Descricao | |---|---| | formataNome(nome) | Primeiro + ultimo nome: Alex Furtunato | | formataNomePessoal(nome) | Nome completo com preposicoes em minusculo: Alex Fabiano de Araujo Furtunato |

formataNome('ALEX FABIANO DE ARAÚJO FURTUNATO')
// 'Alex Furtunato'

formataNomePessoal('ALEX FABIANO DE ARAÚJO FURTUNATO')
// 'Alex Fabiano de Araújo Furtunato'

Datas

| Funcao | Descricao | |---|---| | formataDataRetirandoHora(datastr) | "2025-05-21T17:57:10""21/05/2025" | | formataDataFromDb(datastr) | "2025-05-21""21/05/2025" | | formataDataHoraFromDb(datastr) | Data e hora do banco para pt-BR | | formataDiaMesFromDb(datastr) | "21/05" | | formataDataInt(datastr) | 7022025"07/02/2025" | | mudaFormatoDataSep(datastr) | Alterna entre DD/MM/YYYY e YYYY-MM-DD | | converterParaDataIso(dataString) | DD/MM/YYYYYYYY/MM/DD | | mudaFormatoMesAno(datastr) | Alterna entre MM/YYYY e YYYY-MM | | formataDataMesReferencia(data) | "2025-05""05/2025" | | formatarDataExtrato(data) | Inteiro para data formatada |

Arquivo

| Funcao | Descricao | |---|---| | formataTamanhoArquivo(bytes) | 1024"1 KB" |

Normalizacao

| Funcao | Descricao | |---|---| | removeAcentos(texto) | Remove acentos: "Sao Paulo""Sao Paulo" | | removeMascara(valor) | Remove tudo exceto digitos | | removerPontuacao(valor) | Remove pontuacao de documentos, preserva nomes |

removeAcentos('São Paulo') // 'Sao Paulo'
removeMascara('123.456.789-09') // '12345678909'
removerPontuacao('123.456.789-09') // '12345678909'
removerPontuacao('João da Silva') // 'João da Silva' (mantém)

Mascaras (IMask)

Configuracoes prontas para uso com IMask:

| Constante | Mascara | |---|---| | maskCpf | 000.000.000-00 | | maskCnpj | 00.000.000/0000-00 | | maskCpfCnpj | Dinamica: CPF ou CNPJ conforme digitacao | | maskCep | 00000-000 | | maskTelefone | Dinamica: fixo (00) 0000-0000 ou celular (00) 00000-0000 | | maskNis | 000.00000.00-0 | | maskMoeda | Numero com separador de milhar . e decimal , | | maskData | 00/00/0000 | | maskMesAno | 00/0000 |

import IMask from 'imask'
import { maskCpf } from '@kodatec/brasil-utils'

IMask(element, maskCpf)

Constantes

| Funcao | Descricao | |---|---| | getUfs() | Lista das 27 UFs brasileiras { sigla, nome } | | localePtBr() | Traducao pt-BR para PrimeVue/PrimeReact |

Licenca

MIT