Skip to main content

Remove invisible characters API

Delete zero-width spaces, byte order marks and other characters you cannot see but your parser can.

EndpointPOST https://astraltext.com/api/v1/remove-invisible-characters
AuthBearer token, free
Sendsinput: text
Returnsresult: text
PriceFree. 1,000 calls a day, 60 a minute.

When to call it

Invisible characters are how a copied string breaks a comparison, a database unique index or a URL slug while looking perfectly normal on screen. Stripping them at the point data enters your system is the only reliable place, because nobody will ever spot one in a code review.

For a one-off, the browser version needs no token and never sends your data anywhere: it runs on your own machine.

Example

curl
curl -X POST https://astraltext.com/api/v1/remove-invisible-characters \
  -H "Authorization: Bearer ast_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"input": "user​@example­com"}'
response
{
  "tool": "remove-invisible-characters",
  "result": "user@examplecom",
  "chars": 15,
  "ms": 1
}

In your language

JavaScript
const res = await fetch("https://astraltext.com/api/v1/remove-invisible-characters", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ASTRAL_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"input": "user​@example­com"}),
});
if (!res.ok) throw new Error((await res.json()).detail);
const { result } = await res.json();
Python
import os, requests

res = requests.post(
    "https://astraltext.com/api/v1/remove-invisible-characters",
    headers={"Authorization": f"Bearer {os.environ['ASTRAL_TOKEN']}"},
    json={"input": "user​@example­com"},
    timeout=30,
)
res.raise_for_status()
result = res.json()["result"]

Parameters

FieldTypeNotes
inputstringRequired. Up to 200,000 characters per call.

Errors

Errors are RFC 7807 problem documents with a stable type you can branch on.

missing-token401No Authorization header.
bad-request400input missing or the wrong type.
tool-failed422The input could not be processed. detail says why.
quota-exceeded429Past 1,000 calls today.

Questions

Which characters are removed?
Zero-width space, joiner and non-joiner, the left-to-right and right-to-left marks, the bidirectional overrides, word joiner, invisible operators, the soft hyphen, the Mongolian vowel separator and the byte-order mark.
Are ordinary spaces affected?
No. The ordinary space, tab and newline are untouched. Only characters that render as nothing are removed.
Why would text contain these at all?
They arrive from PDF copy-paste, word processors, chat apps that pad emoji, and model output. Most are added for layout and survive the copy even though the layout does not.

Other endpoints

A token takes thirty seconds

Free, no card, 1,000 calls a day, and the same token works on astraltext.com, astralpdf.com, astraljson.com and astralbatch.com.

Get a free token