Skip to content

Laranon anonymises PII before it reaches an LLM, then restores it

A new Laravel package tokenises personal data before sending text to a model and reverses the tokens once the reply comes back, so raw PII never leaves your server.

Source: Laravel News

Eduardo Lázaro released Laranon on 20 November: a Laravel package that anonymises personal data in text before it reaches an LLM, then restores the real values in the model’s reply.

Laranon::anonymize() swaps PII for tokens such as «SSN_1», keeping the token map on your server, in memory, an encrypted cache, or a database, and restore() reverses it once the model answers. Token replacement is the default for round-tripping to an LLM, with faker and redact strategies alongside it for producing readable fake data or write-only labels in logs. Spanish and English recognizer packs cover IBANs, credit cards, SSNs, UK National Insurance numbers and Spanish DNI, NIE and CIF numbers, with checksum validation on the financial and identity ones. It needs PHP 8.2 and Laravel 12, and restoration works on streamed SSE chunks too.

$result = Laranon::scope("chat-{$sessionId}")->anonymize(
    'Our client John Smith, SSN 536-90-4399, requests...'
);
$reply = $chat->send($result->text);
$result->restore($reply);

Why it matters: anyone wiring customer data into a prompt has either redacted it by hand or skipped that step. A maintained package that anonymises and restores in two calls makes it easy to stop sending raw PII to a third-party model.

The caveat: Laranon is MIT-licensed but brand new, with no tagged release yet, so check how it handles your specific data before trusting it with real customer records.

Share

Related reading

More from The Wire

All briefs