The Code Codex
Theme

CPF Generator & Validator

Generate valid Brazilian CPF numbers for testing (by state) and validate or format existing ones.

The link keeps what is on screen.

Fictitious data generated by algorithm, valid only in format. Use for testing only — never to impersonate a person or company.

Generate

Result

    Validate

    How is it calculated?
    The last two digits are check digits: weighted sum of the first 9 (weights 10 to 2) modulo 11; the second repeats it over 10 digits (weights 11 to 2). The 9th digit encodes the tax region.
    See the code ↗

    Processed in your browser; nothing is sent.

    ⌨️ Use from the terminal (JSON)

    This tool also runs outside the site: the cli.js script uses the same logic as this page and returns the result as JSON. Parameters are the same as this page's URL — copy the command below with the values on screen.

    Deno
    deno run -q "https://thecodecodex.com/cli.js?tool=cpf"
    Node.js / Bun
    curl -s https://thecodecodex.com/cli.js | node --input-type=module - cpf q=…
    ParameterDescriptionDefault
    qquantidade (1-50)1
    ufestado de emissão—
    mask1 = com máscara1
    vCPF para validar—

    Requires Deno, Node.js or Bun. With Deno the script runs with no permissions: it cannot read files or access the network. Central Bank indicators are from the day the site was published.

    More in Documents & PDF