Guide · Chile utilities

Chile RUT validation API: check digit, format and batches as JSON for your code and your AI agents

How to validate Chilean RUT numbers from your code or an AI agent: check the verification digit with the modulo 11 algorithm, accept formats with and without dots, compute the check digit when you only have the body and validate whole lists. With Better Llama's MCP tool, no key or sign-up, and no personal data lookups.

What does validating a RUT mean?

The RUT (Rol Único Tributario, Chile's tax ID) has a numeric body and a check digit (DV, dígito verificador) from 0 to 9 or the letter K: in 12.345.678-5, the body is 12345678 and the check digit is 5. The check digit is computed from the body with the modulo 11 algorithm, so validating a RUT means checking that the written digit matches the computed one. That catches most typos in forms, spreadsheets and databases.

Validating is not verifying: a RUT with a correct check digit may not exist or may not belong to whoever typed it. Our tool chile_calendar_and_rut, with operation validar_rut, does the calculation locally: it does not query the SII (Chile's tax authority) or any database, and it returns no names. In the query of Monday, November 23, 2026 at 14:19 (Chile time), 12.345.678-5 came back with "valid": true and the normalized format.

The same tool computes public holidays and business days; that is covered in the Chile public holidays API guide. This guide focuses on the RUT: the algorithm, formats, errors, batches and privacy.

How the check digit is computed (modulo 11)

  1. Take the digits of the body from right to left.
  2. Multiply each one by the weights 2, 3, 4, 5, 6 and 7; after 7, start again at 2.
  3. Add up the products and take the remainder of dividing the sum by 11.
  4. Subtract that remainder from 11. If the result is 11, the check digit is 0; if it is 10, the check digit is K; otherwise, it is that number.

Example with the body 12.345.678:

Digit × weight (right to left)Product
8 × 216
7 × 321
6 × 424
5 × 525
4 × 624
3 × 721
2 × 24
1 × 33
Sum138

The sum is 138; 138 divided by 11 leaves a remainder of 6, and 11 − 6 = 5. That is why the full RUT is 12.345.678-5.

The same algorithm in Python, with no dependencies:

python
def check_digit(body: int) -> str:
    total, weight = 0, 2
    for d in reversed(str(body)):
        total += int(d) * weight
        weight = 2 if weight == 7 else weight + 1
    rest = 11 - total % 11
    return "0" if rest == 11 else "K" if rest == 10 else str(rest)

for body in (12345678, 80808080, 99887766):
    print(body, check_digit(body))

Real output:

output
12345678 5
80808080 K
99887766 0

If you only need to validate a field in your form, this function is enough. The API pays off when an AI agent does the validation, when you want the same result in all your systems (with the normalized format and a clear error message) or when you validate whole lists in a single call. In a form, validate when the user leaves the field (not only on submit) and announce the error to screen readers, for example with role="alert".

Step by step: validate RUTs by API

Step 1. Choose the operation

Use operation validar_rut and put the RUTs in ruts, as text. If you only have the body and want the check digit, add rutBodyOnly true.

Step 2. Connect the MCP server

Use the MCP https://mcp.betterllama.com/mcp in your client (configuration below) or call it over HTTP with JSON-RPC. No key or sign-up is needed during the beta.

Step 3. Call the tool

With curl:

curl
curl -s https://mcp.betterllama.com/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "chile_calendar_and_rut", "arguments": {"operation": "validar_rut", "ruts": ["12.345.678-5"]}}}'

Real, complete response (November 23, 2026, 14:19 Chile time):

json
{
  "tool": "chile_calendar_and_rut",
  "count": 1,
  "results": [
    {
      "kind": "rut",
      "input": "12.345.678-5",
      "valid": true,
      "body": 12345678,
      "dv": "5",
      "expectedDv": "5",
      "normalized": "12345678-5",
      "formatted": "12.345.678-5",
      "personType": "persona_natural"
    }
  ],
  "warnings": [],
  "stopReason": "completed",
  "attribution": "Calculado por Better Llama a partir de leyes de feriados y la División Político-Administrativa publicadas por el Estado de Chile.",
  "source": "https://betterllama.com/",
  "retrievedAt": "2026-11-23T17:19:53.594Z"
}

In Python, validate the RUTs that arrive from a web form:

python
import json
import requests

URL = "https://mcp.betterllama.com/mcp"
HEADERS = {"Accept": "application/json, text/event-stream"}

def validate_ruts(ruts):
    body = {"jsonrpc": "2.0", "id": 1, "method": "tools/call",
            "params": {"name": "chile_calendar_and_rut",
                       "arguments": {"operation": "validar_rut", "ruts": ruts, "maxItems": 1000}}}
    resp = requests.post(URL, json=body, headers=HEADERS, timeout=60)
    resp.raise_for_status()
    return json.loads(resp.json()["result"]["content"][0]["text"])["results"]

# Example RUTs, as they would arrive from a web form
form = ["12.345.678-5", "123456785", "12.345.678-9", "80.808.080-k", "ABC-1"]
for r in validate_ruts(form):
    if r["valid"]:
        print("OK     ", r["input"], "->", r["formatted"])
    else:
        print("REJECT ", r["input"], "->", r["error"])

Real output (November 23, 2026, 14:20 Chile time). Error messages come in Spanish:

output
OK      12.345.678-5 -> 12.345.678-5
OK      123456785 -> 12.345.678-5
REJECT  12.345.678-9 -> dígito verificador incorrecto
OK      80.808.080-k -> 80.808.080-K
REJECT  ABC-1 -> formato inválido (esperado 12.345.678-5)

In JavaScript (Node.js 18 or later, as an .mjs module), compute the check digit from the body:

javascript
const URL = "https://mcp.betterllama.com/mcp";

async function computeDv(bodies) {
  const resp = await fetch(URL, {
    method: "POST",
    headers: { "Content-Type": "application/json", Accept: "application/json, text/event-stream" },
    body: JSON.stringify({
      jsonrpc: "2.0", id: 1, method: "tools/call",
      params: { name: "chile_calendar_and_rut",
                arguments: { operation: "validar_rut", ruts: bodies, rutBodyOnly: true } },
    }),
  });
  const data = await resp.json();
  return JSON.parse(data.result.content[0].text).results;
}

for (const r of await computeDv(["12345678", "80808080", "99887766"])) {
  console.log(r.body, "DV", r.expectedDv, r.formatted, r.personType);
}

Real output:

output
12345678 DV 5 12.345.678-5 persona_natural
80808080 DV K 80.808.080-K persona_juridica
99887766 DV 0 99.887.766-0 persona_juridica

Step 4. Use the result

Each RUT comes back with input (what you sent), valid, body, dv (the written or computed check digit), expectedDv and personType. Valid ones also include normalized (no dots, with a hyphen, like 12345678-5), ideal for storing in your database, and formatted (with dots, like 12.345.678-5), for display. Invalid ones include error.

Accepted formats: with dots, without dots and without a hyphen

The tool accepts the RUT with dots and hyphen, with a hyphen only or all together (the last character is taken as the check digit), and K in upper or lower case. Real results of a single call with seven example RUTs:

InputvalidResult (formatted or error)
12.345.678-5true12.345.678-5
12345678-5true12.345.678-5
123456785true12.345.678-5
12.345.678-9falsedígito verificador incorrecto
11.111.111-1true11.111.111-1
80.808.080-ktrue80.808.080-K
99.887.766-0true99.887.766-0

The first three are the same RUT written three ways: all three come back with the same normalized. The lower-case k comes back in upper case.

Common errors and what the API returns

When a RUT is not valid, the response explains why in error (in Spanish). Real results:

InputvalidResult (formatted or error)
12.345.678falsedígito verificador incorrecto
ABC-1falseformato inválido (esperado 12.345.678-5)
0-0falsecuerpo inválido
1234567890-1falseformato inválido (esperado 12.345.678-5)

Watch the first one: 12.345.678 with no hyphen or check digit is read as body 1,234,567 with check digit 8, and the expected digit for that body is 4. If your data only has the body, use rutBodyOnly true and the tool computes the check digit instead of rejecting it.

If you call validar_rut without RUTs, the tool returns an error (isError) with the message "validar_rut" requiere al menos un RUT en "ruts".

Validate batches of RUTs in one call

You can send up to 5,000 RUTs per call, but the response holds at most maxItems results: 50 by default and up to 1000. In a real test with 120 example bodies and no maxItems, the response had 50 results and "stopReason": "maxItems"; with "maxItems": 1000 it had all 120 and "stopReason": "completed".

  • For lists of more than 1000 RUTs, split them into blocks of 1000 and check stopReason in each response.
  • Repeated RUTs with the same text come back once: 3 entries (12.345.678-5 twice and 12345678-5) gave 2 results. To match them with your rows, use input.
  • The beta limit is 60 requests per minute per IP; a batch in a single call counts as one request.

Privacy: what the tool does not do

Validation is only a calculation: it does not query the SII, the Civil Registry or any other source, it returns no names or addresses and it does not store the RUTs you send. The personType field is an approximate rule on the number, not a lookup: bodies below 50,000,000 are marked persona_natural (individual) and the rest persona_juridica (legal entity).

Individuals' RUTs are personal data under Chilean law (Laws 19.628 and 21.719). That is why every RUT in this guide is an example, and why our other tools omit individuals' data.

Validate RUTs from your AI agent (MCP)

Add the Better Llama MCP server to your client (Claude, Cursor, VS Code or any other with remote MCP). One MCP brings chile_calendar_and_rut and the rest of the catalog, with no sign-up during the beta.

Cursor · mcp.json
{
  "mcpServers": {
    "better-llama": {
      "url": "https://mcp.betterllama.com/mcp"
    }
  }
}
Claude Code
claude mcp add --transport http better-llama https://mcp.betterllama.com/mcp

Setup for Claude, Codex, Gemini CLI, Windsurf, VS Code and other clients: connect your agent.

Ready-to-run Python and Node.js examples, with config files for each client: examples repository on GitHub.

Then ask, for example: "Check this column of RUTs and tell me which ones have a wrong check digit." or "Compute the check digit for these RUT bodies and return them with dots and hyphen." The agent calls the tool instead of doing the arithmetic from memory, which is where models often get it wrong.

Beta: free and with no sign-up while we test the service.

Pricing

Free during the beta, no sign-up, with a limit of 60 requests per minute per IP. If paid plans come later, we will announce them first on betterllama.com.

Frequently asked questions

How is a Chilean RUT validated?

The check digit is computed from the body with the modulo 11 algorithm and compared with the written digit. If they match, the RUT is valid. With Better Llama you do it by API with chile_calendar_and_rut and operation validar_rut, with no key.

Is there a free API to validate RUTs?

Yes. The chile_calendar_and_rut tool on the Better Llama MCP validates RUTs for free during the beta, with no sign-up, over MCP or JSON-RPC, with a limit of 60 requests per minute per IP.

Does validating a RUT confirm it exists or who owns it?

No. Validation only checks that the check digit is correct. It does not query the SII or any database and returns no names.

Which formats are accepted?

With dots and hyphen (12.345.678-5), with a hyphen only (12345678-5) or all together (123456785), with K in upper or lower case. If you only have the body, use rutBodyOnly true.

How do I compute a RUT check digit?

Send the body in ruts with rutBodyOnly true and read expectedDv and formatted in the response. You can also use the Python function in this guide, which applies the same algorithm.

How many RUTs can I validate per call?

Up to 5,000 RUTs per call, with up to 1000 results per response depending on maxItems (50 by default). For bigger lists, split them into blocks of 1000.

What does personType mean?

It is an approximate rule on the number: bodies below 50,000,000 are marked persona_natural (individual) and the rest persona_juridica (legal entity). It is not a lookup in any registry.

Is Better Llama affiliated with the SII?

No. Better Llama is an independent project, not affiliated with, sponsored by or endorsed by Chile's Servicio de Impuestos Internos or the Government of Chile.

Keep going

Other guides

This guide is also available en español.