Sanitext

Detect and Redact URLs in Text

Sanitext detects URLs in text and labels each one URL. POST text to /v1/detect to get spans with byte offsets, a confidence score, and the matched link. POST to /v1/redact to replace every URL with [URL]. It catches full, bare, and query-string links across 30+ languages.

URLs in text quietly leak identity: profile links, tracking parameters, and paths with user IDs. Sanitext finds them and labels each one URL. Use /v1/detect for byte-offset spans and scores, or /v1/redact to mask every link as [URL] across 30+ languages.

URL detection: /v1/detect vs /v1/redact

Aspect/v1/detect/v1/redact
OutputSpans with label, byte offsets, score, matched textOriginal text with URLs replaced by [URL]
Use whenYou need to review, score, or log link locationsYou need clean text with links removed
URL labelYes, label: URLMasked as [URL]
Covers query strings and pathsYesYes
Languages30+30+

What counts as a URL?

Sanitext flags web links of all shapes, not just clean https addresses. The model returns the label URL for each match. URLs matter for privacy because a link path or query string often carries a user ID, a session token, or a tracking parameter that points back to one person.

  • —Full links: https://acme.io/users/48213?ref=email
  • —Scheme-less links: www.acme.io
  • —Bare domains: acme.io, sub.acme.co.uk
  • —Links with paths, query strings, and fragments
  • —Tracking and referral parameters inside the query string
  • —Numeric IDs and slugs embedded in the path

How does URL detection work?

Send your text to /v1/detect. For every URL the API returns a span with five fields: label (URL), start byte offset, end byte offset, a confidence score between 0 and 1, and the exact matched text.

Byte offsets are precise, so you can slice the original string, highlight the link, or apply your own masking. The score lets you set a threshold and drop low-confidence matches. To mask instead, POST the same text to /v1/redact and every URL span comes back replaced inline with [URL].

We run our own open-weights model on Cloudflare infrastructure. Your text never goes to a third-party LLM, and we keep no raw text. We log counts and timings only.

Which URL formats and edge cases are handled?

Real text is messy, so URL detection has to handle more than the textbook case. Sanitext spans the whole link, including the path, query string, and fragment, so tracking parameters and IDs inside the URL are covered when you redact.

It catches links wrapped in parentheses, links at the end of a sentence before punctuation, and multiple links in one line as separate spans. Bare domains and www links without a scheme are still labeled URL. Note that email addresses are returned under the EMAIL label, not URL, so you can handle them separately.

  • —Links inside parentheses or quotes
  • —Trailing punctuation trimmed from the span
  • —Multiple links per line as distinct spans
  • —Subdomains and multi-part TLDs (.co.uk)
  • —Query strings, fragments (#section), and ports

Does URL detection work in other languages?

Yes. Sanitext detects URLs across 30+ languages, including Spanish, French, German, Dutch, Portuguese, and Italian. URLs are mostly language-neutral, but the surrounding words and punctuation are not, and the model uses that context to set span boundaries correctly. Localized link text and non-Latin scripts around the link do not break detection.

bash

curl https://api.sanitext.app/v1/detect \
  -H "Authorization: Bearer $SANITEXT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "Read more at https://acme.io/users/48213?ref=email and www.acme.io"}'

# Response
{
  "spans": [
    {
      "label": "URL",
      "start": 13,
      "end": 49,
      "score": 0.99,
      "text": "https://acme.io/users/48213?ref=email"
    },
    {
      "label": "URL",
      "start": 54,
      "end": 65,
      "score": 0.97,
      "text": "www.acme.io"
    }
  ]
}

# Same text via /v1/redact
# -> "Read more at [URL] and [URL]"

FAQ

Does Sanitext detect bare domains without https?+

Yes. Sanitext labels bare domains like example.com and scheme-less links like www.acme.io as URL, alongside full https links. Each match returns byte offsets, a score, and the exact matched text so you can verify it before redacting.

How do I replace URLs with a placeholder?+

POST your text to /v1/redact. Every detected URL span is replaced inline with [URL], leaving the rest of the text intact. Use /v1/detect first if you want spans and scores instead of a masked string.

Will it remove tracking parameters and IDs in the URL?+

Yes. Sanitext spans the whole URL, including the path, query string, and fragment. So tracking parameters, session tokens, and numeric user IDs inside the link are covered when you redact the span.

Is redacting URLs enough to anonymize my data?+

No. Redacting URLs is a data-minimization aid, not anonymization or a compliance guarantee. Combine it with other entity types, review output for high-stakes uses, and follow your own legal and security policies.

Redact URLs in 60 seconds

Sign up free for 300K characters, no card. Drop in your API key and curl /v1/redact to mask every link as [URL]. See live spans in the playground or read the docs.

Get your free API key